From 72e0fb17afa01c465752a29f10690b8341f98a9d Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 13:17:23 -0500 Subject: [PATCH 01/24] =?UTF-8?q?=E2=9C=A8=20hub:=20point=20owners=20to=20?= =?UTF-8?q?their=20spoke=20dashboard=20and=20the=20row=20=E2=8B=AF=20menu?= =?UTF-8?q?=20(#16589)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ✨ hub: point owners to their spoke dashboard and the row ⋯ menu New owners land on the hub's My Hives and look for the Guide, settings and GitHub App install that live inside their hive (the spoke). Today an owner read "Open your hive dashboard → Guide (top navbar)" on the hub and replied "I do not see any guide or setting option". - Dismissible per-hive callout above the list: "Your hive is ready → Open your hive ↗", that the hub only lists hives, the attention item that must be fixed inside the hive (Open it → Guide → Install the Forge App), and that the row ⋯ menu manages permissions, pause, funding, delete. Admin viewers never see it; >2 hives collapse to one compact callout. - Dismissal stored in localStorage per user + hive as the attention kinds seen; re-shown only when a new kind appears. - Hive-name link gains an ↗ glyph, tooltip and a brief spotlight; the ⋮ button gains a "Manage: permissions, pause, funding, delete…" hint. - No native dialogs; ux test + changelog fragment. Signed-off-by: Andrew Anderson * 🌱 hub: express spoke pointer via design tokens; keyboard-open the ⋮ menu Keeps TestStyleRatchet at baseline: the new .spoke-* block adds no raw colors, font-sizes, paddings or radii, and the container uses the hidden attribute instead of an inline style. The ⋮ glyph advertised role=button without a keyboard path; the dropdown now opens on :focus-within and Enter/Space/ArrowDown move focus into the first item, Escape closes. Signed-off-by: Andrew Anderson --------- Signed-off-by: Andrew Anderson --- changelog.d/added-hub-spoke-pointer.md | 1 + src/pkg/hub/assets/dashboard.html | 238 +++++++++++++++++- src/pkg/hub/saas_dashboard_myhives_ux_test.go | 50 ++++ 3 files changed, 286 insertions(+), 3 deletions(-) create mode 100644 changelog.d/added-hub-spoke-pointer.md diff --git a/changelog.d/added-hub-spoke-pointer.md b/changelog.d/added-hub-spoke-pointer.md new file mode 100644 index 0000000000..db345009fb --- /dev/null +++ b/changelog.d/added-hub-spoke-pointer.md @@ -0,0 +1 @@ +- Hub My Hives: a dismissible "Your hive is ready → Open your hive ↗" callout for owners explains that the hub only lists hives (the Guide, settings and GitHub App install live inside the hive), names any attention item that must be fixed there, and points at the row ⋯ menu; the hive-name link gains an ↗ glyph and tooltip and the ⋮ button a "Manage: permissions, pause, funding, delete…" hint. Dismissal is per user and hive in localStorage and re-arms when a new attention item appears. diff --git a/src/pkg/hub/assets/dashboard.html b/src/pkg/hub/assets/dashboard.html index af2e39022e..b4aa0af25f 100644 --- a/src/pkg/hub/assets/dashboard.html +++ b/src/pkg/hub/assets/dashboard.html @@ -260,7 +260,8 @@ .hive-group-head:hover td { color: var(--text) !important; } .hive-group-caret { display: inline-block; width: 12px; font-size: 0.7rem; } .table-wrap { overflow: visible; margin: 0 auto; position: relative; } - .hive-menu-cell:hover .hive-menu-dropdown { display: block !important; } + .hive-menu-cell:hover .hive-menu-dropdown, + .hive-menu-cell:focus-within .hive-menu-dropdown { display: block !important; } .hive-menu-item { display: block; padding: var(--sp-3) var(--sp-5); color: var(--text); text-decoration: none; font-size: var(--fs-sm); cursor: pointer; } .hive-menu-dropdown a:hover, .hive-menu-dropdown div[onclick]:hover { background: color-mix(in srgb,var(--hub-dashboard-accent) 8%,transparent); border-radius: var(--r-sm); } .table-wrap::-webkit-scrollbar { height: 10px; display: block; } @@ -613,6 +614,40 @@ .repo-link { color: var(--blue); font-size: 0.8rem; } .hive-name-link { color: #58a6ff; font-weight: 700; text-decoration: none; } .hive-name-link:hover { color: #79c0ff; text-decoration: underline; } + /* "Open hive ↗" affordance on the hive-name link. A new owner reads the + bold name as a label, not a door: the glyph says it leaves the hub. Kept + faint at rest and lifted on hover so dense rows stay quiet. */ + .hive-name-link .open-glyph { display: inline-block; opacity: 0.55; font-size: var(--fs-xs); margin-left: 4px; transform: translateY(-2px); transition: opacity var(--duration-fast), transform var(--duration-fast); } + .hive-name-link:hover .open-glyph { opacity: 1; transform: translate(1px, -3px); } + + /* ── Spoke pointer ── + The hub LISTS hives; a hive's own dashboard, Guide, settings and GitHub + App install live inside the hive (the spoke). New owners miss that and + hunt the hub for a Guide that is not here, so this callout names their + hive, links it with the SAME href the row uses, and says where the ⋯ row + menu is. Rendered by renderSpokePointer(); dismissal is per user + hive + in localStorage and re-arms when a NEW attention kind appears. */ + #spoke-pointer { margin-bottom: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); } + #spoke-pointer[hidden] { display: none; } + .spoke-callout { position: relative; border: 1px solid color-mix(in srgb, var(--hub-dashboard-accent) 45%, transparent); border-left: 4px solid var(--hub-dashboard-accent); border-radius: var(--r-lg); background: color-mix(in srgb, var(--hub-dashboard-accent) 9%, var(--surface)); padding: var(--sp-5) calc(var(--sp-9) + var(--sp-5)) var(--sp-5) var(--sp-6); display: grid; gap: var(--sp-3); } + .spoke-callout-title { font-size: var(--fs-md); font-weight: 700; display: flex; align-items: center; gap: var(--sp-4); flex-wrap: wrap; } + .spoke-callout-title .hive-name-link { font-size: var(--fs-lg); } + .spoke-open-btn { display: inline-flex; align-items: center; gap: var(--sp-3); background: var(--brand); color: var(--surface-0); font-weight: 700; font-size: var(--fs-sm); padding: var(--sp-2) var(--sp-5); border-radius: var(--r-pill); text-decoration: none !important; } + .spoke-callout-line { font-size: var(--fs-base); color: var(--muted); line-height: 1.5; } + .spoke-callout-line b { color: var(--text); font-weight: 600; } + .spoke-callout-fix { font-size: var(--fs-base); color: var(--text); display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; } + .spoke-callout-fix .spoke-warnmark { color: var(--status-warn); } + .spoke-callout-crumb { display: inline-flex; align-items: center; gap: var(--sp-3); } + .spoke-callout-crumb span { background: color-mix(in srgb, var(--text) 6%, transparent); border: 1px solid var(--border); border-radius: var(--r-sm); padding: var(--sp-1) var(--sp-3); font-size: var(--fs-xs); font-weight: 600; } + .spoke-callout-dismiss { position: absolute; top: var(--sp-4); right: var(--sp-4); background: none; border: 1px solid transparent; color: var(--muted); font-size: var(--fs-lg); line-height: 1; width: var(--sp-8); height: var(--sp-8); border-radius: var(--r-sm); cursor: pointer; font-family: inherit; } + .spoke-callout-dismiss:hover { border-color: var(--border); color: var(--text); background: color-mix(in srgb, var(--text) 5%, transparent); } + .spoke-kbd-dots { display: inline-grid; place-items: center; min-width: var(--sp-7); height: var(--sp-6); padding: var(--sp-0) var(--sp-2); border: 1px solid var(--border); border-radius: var(--r-sm); background: color-mix(in srgb, var(--text) 5%, transparent); font-size: var(--fs-base); line-height: 1; color: var(--text); vertical-align: -3px; } + /* Spotlight on the row link the callout points at: the same blue the + "Attention needed" jump uses (.hive-row-targeted), pulsing briefly so + the eye lands on the link and then rests. */ + .spoke-spot { border-radius: var(--r-sm); animation: spokeSpotPulse 1.3s ease-out 3; } + @keyframes spokeSpotPulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--hub-dashboard-accent) 65%, transparent); } 70% { box-shadow: 0 0 0 var(--sp-5) transparent; } 100% { box-shadow: 0 0 0 0 transparent; } } + @media (prefers-reduced-motion: reduce) { .spoke-spot { animation: none; box-shadow: 0 0 0 2px color-mix(in srgb, var(--hub-dashboard-accent) 65%, transparent); } } .hive-sub-link { color: #6b7280; font-weight: 400; text-decoration: none; } /* Inline action inside the restart-storms pill: inherits the pill's font/colour so it never inflates the pill. */ .reset-agent-restarts { all: unset; cursor: pointer; margin-left: var(--sp-2); padding-left: var(--sp-2); border-left: 1px solid; border-color: inherit; font: inherit; color: inherit; text-decoration: underline; text-underline-offset: 2px; } @@ -796,6 +831,10 @@

+ + @@ -4479,8 +4518,15 @@

' + + '' + esc(labels.join(', ')) + ' needs fixing inside your hive: ' + + 'Open it → 🧭 Guide → Install the Forge App'; + } + + var SPOKE_POINTER_LIST_LINE = '
The hub only lists hives. Your hive’s own dashboard, 🧭 Guide, settings and the GitHub App install live inside the hive.
'; + var SPOKE_POINTER_MENU_LINE = '
Use ⋮ on your hive’s row to manage permissions, pause, funding or delete.
'; + + function spokeDismissButton(idsCsv) { + return ''; + } + + function spokeCalloutFull(h) { + var name = hiveLabel(h).line1 || h.name || h.id; + return '
' + + '
Your hive' + spokeOpenLink(h, name, 'hive-name-link') + + 'is ready→' + spokeOpenLink(h, 'Open your hive ↗', 'spoke-open-btn') + '
' + + SPOKE_POINTER_LIST_LINE + spokePointerFixLine(h) + SPOKE_POINTER_MENU_LINE + + spokeDismissButton(String(h.id)) + '
'; + } + + function spokeCalloutCompact(hives) { + var links = hives.map(function(h) { return spokeOpenLink(h, hiveLabel(h).line1 || h.name || h.id, 'hive-name-link'); }).join(' · '); + var needFix = hives.filter(function(h) { return spokeAttentionKinds(h).length > 0; }); + var fix = needFix.length + ? '
' + + esc(needFix.map(function(h) { return hiveLabel(h).line1 || h.name || h.id; }).join(', ')) + ' ' + + (needFix.length === 1 ? 'needs' : 'need') + ' fixing inside the hive: ' + + 'Open it → 🧭 Guide → Install the Forge App
' + : ''; + var ids = hives.map(function(h) { return String(h.id); }).join(','); + return '
' + + '
Your hives are ready→' + links + '
' + + SPOKE_POINTER_LIST_LINE + fix + SPOKE_POINTER_MENU_LINE + spokeDismissButton(ids) + '
'; + } + + /* renderSpokePointer draws the callout(s) for the viewer's own hives: + assigned (non-placeholder) hives with a usable link, owners first and + hives with attention before quiet ones, minus the ones dismissed. */ + function renderSpokePointer(assignedHives) { + var el = document.getElementById('spoke-pointer'); + if (!el) return; + _spokePointerHives = (assignedHives || []).filter(function(h) { return h && h.id && !isPlaceholderHive(h) && spokeOpenLink(h, 'x', 'hive-name-link'); }); + if (_isAdmin || !_spokePointerHives.length) { el.hidden = true; el.innerHTML = ''; return; } + var show = _spokePointerHives.filter(function(h) { return !spokePointerDismissed(h); }); + if (!show.length) { el.hidden = true; el.innerHTML = ''; return; } + show.sort(function(a, b) { + var ao = a.role === 'owner' ? 0 : 1, bo = b.role === 'owner' ? 0 : 1; + if (ao !== bo) return ao - bo; + var aa = spokeAttentionKinds(a).length ? 0 : 1, ba = spokeAttentionKinds(b).length ? 0 : 1; + if (aa !== ba) return aa - ba; + return String(a.name || a.id).localeCompare(String(b.name || b.id)); + }); + el.innerHTML = show.length <= SPOKE_POINTER_MAX_FULL + ? show.map(spokeCalloutFull).join('') + : spokeCalloutCompact(show); + el.hidden = false; + /* Spotlight the row link the callout points at, once per hive per page + load. Deferred: renderHives draws the table AFTER this callout. */ + setTimeout(function() { + show.forEach(function(h) { + if (_spokeSpotDone[h.id]) return; + var row = document.getElementById(hiveRowDomId(h.id)); + var link = row ? row.querySelector('.hive-name-link') : null; + if (!link) return; + _spokeSpotDone[h.id] = true; + link.classList.add('spoke-spot'); + }); + }, 0); + } + function renderHives(allHives, force) { allHives = allHives || []; /* Defer the whole render while a branch/channel menu is open. Skipping @@ -8613,6 +8842,9 @@

' + bulkCheckboxCell(h, section || 'all') + - '' + ('⋮' + pendingBadge + '') + '' + + '' + ('⋮' + pendingBadge + '') + '' + '' + (function() { var isHostedRow = h.hiveType === 'hosted' || (h.id && (h.id.startsWith('hosted-') || h.id.startsWith('saas-'))); var dh = isHostedRow && h.id ? ('/api/saas/hives/' + encodeURIComponent(h.id) + '/open') : (rb ? esc(rb) : ''); /* Label derived from the PROJECT (org + primary repo), not by splitting h.name — see hiveLabel. */ var label = hiveLabel(h); var orgName = label.line1; var repoName = label.line2; /* rp is the repo path shown in the GitHub-icon tooltip; use the same doubling-safe path the label shows (repoDisplayLine / hiveLabel), never org + '/' + primaryRepo which doubles the owner on a github.io/GHE hive whose primaryRepo is already 'owner/repo'. */ var rp = repoName || ''; /* The icon href must resolve to a real GitHub path. When primaryRepo already carries 'owner/repo', that pair IS the owner/repo the URL needs (not org, which may be a mis-parsed host); otherwise fall back to org + primaryRepo. */ var hasRepoPath = h.primaryRepo && h.primaryRepo.indexOf('/') !== -1; var rpOwner = hasRepoPath ? h.primaryRepo.split('/')[0] : h.org; var rpName = hasRepoPath ? h.primaryRepo.split('/').slice(1).join('/') : h.primaryRepo; var rpHref = ghRepoURL(hiveForgeHost(h), rpOwner, rpName); var ghIcon = (rp && rpHref) ? '' : (rp ? '' : ''); /* vanityDisplay is the friendly host shown in the status bar on hover. rb is resolvedBase(h), which the hub has already overlaid with the claimed vanity_url; it is only a DISPLAY url here, never the click target — see ssoDisplayLink. Empty for a row with no vanity host, which falls back to today's /open href. Only meaningful on hosted rows: a non-hosted row's dh IS rb already. */ var vanityDisplay = isHostedRow && rb ? rb : ''; var link = function(text, bold) { if (dh) { return ssoDisplayLink(dh, vanityDisplay, text, bold ? 'hive-name-link' : 'hive-sub-link'); } var s = bold ? 'font-weight:700;color:inherit' : 'color:#6b7280;font-weight:400'; return '' + esc(text) + ''; }; /* repoLink wraps the second line (the org/repo) in a link to the ACTUAL FORGE REPO (github.com / GHE host), NOT the spoke dashboard: the top line already opens the dashboard, so the repo path should take an operator to the code. rpHref is the same doubling-safe forge URL the GitHub icon uses (ghRepoURL(hiveForgeHost(h), rpOwner, rpName)); when it is empty (BYO/mis-parsed host) fall back to plain non-link text, never to the dashboard. */ var repoLink = function(text) { if (rpHref) { return '' + esc(text) + ''; } return '' + esc(text) + ''; }; var line1 = dot + ' ' + link(orgName, true) + heartbeatHeart(h) + nameEditAffordance(h); var fcPill = h.online ? failingCheckSummary(h) : ''; /* Advisory-staleness pill sits right beside the failing-check pill: both are "something is quietly wrong with this working hive" signals, and advisoryStaleSummary already self-suppresses (empty string) unless the hub flagged the digest stale, so unaffected rows are pixel-identical. */ var advPill = h.online ? advisoryStaleSummary(h) : ''; /* Advisory finding-count pill rides beside the staleness pill and carries the "(top N)" marker when the spoke capped its digest. */ var advCountPill = h.online ? advisoryFindingsSummary(h) : ''; /* Dead-link pill is deliberately NOT gated on h.online: the entire point is a hive that IS online and heartbeating while its public URL is broken, so gating it the way the other pills are gated would hide exactly the case it exists to surface. */ var dlPill = deadLinkSummary(h); var privatePill = privateURLSummary(h); /* Inference-auth pill: like the dead-link pill it is NOT gated on h.online, because the hive being online while every inference call 401s is exactly the case it surfaces. */ var iaPill = inferenceAuthSummary(h); var rsPill = restartStormSummary(h); /* Inline access faces sit on the name cell's second line, immediately after this row's own role badge: the badge already answers "what am I on this hive", so the co-members read as the natural continuation of the same thought, in the one cell that is left-aligned and has room to grow. It also keeps them out of the 16 dense metric columns, none of which is about people. Empty string when the viewer is the only member, so those rows are pixel-identical to today. */ var accessFaces = hiveAccessAvatars(h); /* Keyed off repoName, not orgName: line 1 now always carries SOME identity, so the presence of a second line is decided purely by whether there is a repo to put on it. Without a repo the row still shows the GitHub icon, role badge, faces and failing-check pill on the compact variant. */ var line2 = repoName ? '
' + repoLink(repoName) + ' ' + ghIcon + ' ' + roleBadge(h.role) + accessFaces + fcPill + advPill + advCountPill + dlPill + privatePill + iaPill + rsPill + '
' : '
' + ghIcon + ' ' + roleBadge(h.role) + accessFaces + fcPill + advPill + advCountPill + dlPill + privatePill + iaPill + rsPill + '
'; var line3 = pendingPill ? '
' + pendingPill + '
' : ''; return line1 + line2 + line3; })() + '' + '' + locationCell + '' + '' + uptimeCell(h) + '' + diff --git a/src/pkg/hub/saas_dashboard_myhives_ux_test.go b/src/pkg/hub/saas_dashboard_myhives_ux_test.go index a790c68242..296f8c7559 100644 --- a/src/pkg/hub/saas_dashboard_myhives_ux_test.go +++ b/src/pkg/hub/saas_dashboard_myhives_ux_test.go @@ -220,3 +220,53 @@ func TestAssignHiveStillAdminOnlyForUserFirstFlow(t *testing.T) { t.Fatalf("admin assign did not claim the placeholder: %+v", h) } } + +// TestDashboardSpokePointer guards the "your hive is not the hub" callout and +// the two row affordances it points at. The incident it exists for: a new +// owner read "Open your hive dashboard → Guide (top navbar)" on My Hives and +// replied "I do not see any guide or setting option" — because the hub lists +// hives and the Guide lives inside the hive. The callout, the ↗ glyph on the +// hive-name link and the ⋮ hint are all string-built markup, so this is the +// only place their wiring is asserted. +func TestDashboardSpokePointer(t *testing.T) { + html := dashScript(t) + for _, fn := range []string{ + "renderSpokePointer", + "dismissSpokePointer", + "spokeAttentionKinds", + "spokePointerDismissed", + "spokeOpenLink", + } { + if !strings.Contains(html, "function "+fn+"(") { + t.Errorf("dashboardHTML is missing a definition for %s()", fn) + } + } + for _, want := range []string{ + // Container the renderer writes into, above the usage/attention strip. + `id="spoke-pointer"`, + // Drawn from the same render pass as the alerts panel it reads. + "renderAlertsPanel();", + "renderSpokePointer(assignedAll);", + // Dismissal is per viewer + hive and re-arms on a new attention kind. + "LS_SPOKE_POINTER_PREFIX", + "localStorage.setItem(spokePointerKey(", + // The callout's hive link reuses the row's href decision (SSO /open). + "ssoDisplayLink(dh, isHostedRow && rb ? rb : '', text, cls)", + // Row affordances: the ↗ glyph on the bold hive-name link, and the + // ⋮ hint naming what the row menu manages. + `class="open-glyph"`, + "Manage: permissions, pause, funding, delete…", + `title="' + HIVE_MENU_HINT + '"`, + // Copy the incident turned on: where the Guide actually is. + "live inside the hive", + "Install the Forge App", + } { + if !strings.Contains(html, want) { + t.Errorf("dashboardHTML is missing %q", want) + } + } + // Admin viewers never see the callout: their My Hives is the fleet. + if !strings.Contains(html, "if (_isAdmin || !_spokePointerHives.length)") { + t.Error("renderSpokePointer must short-circuit for hub admins") + } +} From 8b0db18886f92b0fcb15f7300ca5c04367ba1c5a Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 13:31:04 -0500 Subject: [PATCH 02/24] =?UTF-8?q?=F0=9F=90=9B=20fix(dashboard):=20a=20part?= =?UTF-8?q?-filled=20CI=20ring=20is=20a=20running=20CI=20chevron=20(#16632?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Check-run motion on the head (in_progress, or queued when nothing runs) now leads every settled word in the required-check path, and the no-required-set path reads motion too, so the CI chevron is active with its count beside a running Review instead of an inactive part-green ring. Red neighbours ride in the running caption ("· 1 failing"); icon-only green is reserved for passed == total. The JS running predicate treats a partial ring with no settled word as running, except on rows parked on a person's decision. Fixes #16631 Signed-off-by: Andrew Anderson --- changelog.d/fixed-ci-partial-ring-running.md | 1 + src/pkg/dashboard/stage_tracker_activity.go | 59 ++++++++++++-- .../dashboard/stage_tracker_activity.test.js | 4 +- .../dashboard/stage_tracker_activity_test.go | 79 +++++++++++++++++-- .../stage_tracker_remediation_chevron.test.js | 24 ++++++ .../static-src/js/tracker-row-strip.js | 20 ++++- src/pkg/dashboard/static/index.html | 20 ++++- 7 files changed, 185 insertions(+), 22 deletions(-) create mode 100644 changelog.d/fixed-ci-partial-ring-running.md diff --git a/changelog.d/fixed-ci-partial-ring-running.md b/changelog.d/fixed-ci-partial-ring-running.md new file mode 100644 index 0000000000..e7c4df5855 --- /dev/null +++ b/changelog.d/fixed-ci-partial-ring-running.md @@ -0,0 +1 @@ +- Activity Monitor: a CI ring that is not yet full now renders the CI chevron active ("CI 13/19 · running") beside a running Review instead of a silent part-green glyph; check-run motion on the head leads red, unreported or ambiguous neighbours, and icon-only green is reserved for a complete ring (hivecommons/hive#16631). diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index e85ee45610..5a9ed9a2f1 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -69,6 +69,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA } if !a.RequiredKnown || a.RequiredSource == "" || len(a.RequiredChecks) == 0 || len(a.Required) == 0 { stageTrackerCountHeadChecks(out, a) + stageTrackerHeadChecksMotion(out, a, now) return out } type requiredObservation struct { @@ -104,6 +105,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA } if !found { stageTrackerCountHeadChecks(out, a) + stageTrackerHeadChecksMotion(out, a, now) return out } } @@ -111,7 +113,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA // Per required-check name: the leading state across its observations, // for the passed / failed counts. perName := map[string]string{} - running := false + running, queued, queuedName := false, false, "" // Per required-check name: which have a final result, for the running count. settled := map[string]bool{} for _, name := range a.Required { @@ -134,6 +136,8 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA } case check.State == "queued" || check.State == "waiting" || check.State == "pending" || check.State == "requested": state = "queued" + queued = true + queuedName = name case check.State == "in_progress": state = "running" running = true @@ -170,6 +174,17 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA if statusesMissing { out.State, out.Blocker = "unknown", "commit statuses not observed" } + // Motion on the head leads every settled word: while any required + // check still runs or waits for a runner the track is running, however + // red, unreported or ambiguous its neighbours are — a ring that is not + // yet full is a running ring, so the chevron stays active with its + // count (hivecommons/hive#16631). The red names ride in ChecksFailing. + switch { + case running: + out.State, out.Blocker = "running", "" + case queued && out.State != "queued": + out.State, out.Blocker = "queued", queuedName + } done := 0 for _, name := range a.Required { if settled[name] { @@ -197,7 +212,11 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA out.Detail = "Required check " + check + " finished without success (failed, timed out, was cancelled, or needs action) on the PR's current commit. A fix or a re-run has to turn it green before CI can pass." case "running": out.Caption = fmt.Sprintf("CI running · %d/%d checks done", done, total) - out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are still executing on the PR's current commit.", done, plural(total, "required check")) + out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are still executing or waiting for a runner on the PR's current commit.", done, plural(total, "required check")) + if out.ChecksFailed > 0 { + out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed) + out.Detail += fmt.Sprintf(" %s already red: %s.", plural(out.ChecksFailed, "required check"), strings.Join(out.ChecksFailing, ", ")) + } case "queued": out.Caption = "CI queued · " + check + " waiting for a runner" out.Detail = "Required check " + check + " has been requested for the PR's current commit but has not started executing yet." @@ -231,10 +250,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA out.Caption = "CI skipped · check " + check + " skipped" out.Detail = "Required check " + check + " finished as skipped or neutral on the PR's current commit, which branch protection does not count as a pass." } - out.Active = running && a.ObservedAt != nil && !a.ObservedAt.After(now) && now.Sub(*a.ObservedAt) <= trackerActivityFreshWindow - if running && out.State != "running" { - out.Caption += " · other checks still running" - } + out.Active = out.State == "running" && a.ObservedAt != nil && !a.ObservedAt.After(now) && now.Sub(*a.ObservedAt) <= trackerActivityFreshWindow return out } @@ -300,6 +316,37 @@ func stageTrackerCountHeadChecks(out *StageTrackerActivity, a *github.PRCIActivi } } +// stageTrackerHeadChecksMotion turns the required-set-unknown count into a +// running track while any check run on the head is still executing or +// queued: the ring is not full, so the chevron must be active with its +// count rather than a silent part-green glyph (hivecommons/hive#16631). +func stageTrackerHeadChecksMotion(out *StageTrackerActivity, a *github.PRCIActivity, now time.Time) { + moving := 0 + for _, check := range a.Checks { + if check.Head != "" && !strings.EqualFold(check.Head, a.Head) { + continue + } + switch check.State { + case "in_progress", "queued", "waiting", "pending", "requested": + moving++ + } + } + if moving == 0 { + return + } + done := out.ChecksTotal - moving + if done < 0 { + done = 0 + } + out.State, out.Blocker = "running", "" + out.Caption = fmt.Sprintf("CI running · %d/%d checks done", done, out.ChecksTotal) + out.Detail = fmt.Sprintf("%d of the %s observed on the PR's current commit have a final result; the rest are still executing or waiting for a runner. Which of them branch protection requires is not yet known.", done, plural(out.ChecksTotal, "check")) + if out.ChecksFailed > 0 { + out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed) + } + out.Active = a.ObservedAt != nil && !a.ObservedAt.After(now) && now.Sub(*a.ObservedAt) <= trackerActivityFreshWindow +} + // stageTrackerExpectedPerspectives is the swarm's perspective set for this // hive: the configured list (built-ins when empty), falling back to the // built-ins when the configuration cannot be resolved. diff --git a/src/pkg/dashboard/stage_tracker_activity.test.js b/src/pkg/dashboard/stage_tracker_activity.test.js index 41ca00b281..71dd40da16 100644 --- a/src/pkg/dashboard/stage_tracker_activity.test.js +++ b/src/pkg/dashboard/stage_tracker_activity.test.js @@ -766,7 +766,7 @@ test('the backend detail sentence rides in the track tooltip, not on the chevron }); test('#16484: count grammar — CI passed/total and Review done/total across every state', () => { - const word = new Function(trackConsts + '\n' + fn(strip, 'stageTrackerWorkflowApprovalPending') + fn(strip, 'stageTrackerQueueAheadWord') + fn(strip, 'stageTrackerHiveOwnsRepair') + fn(strip, 'stageTrackerTrackWord') + ';return stageTrackerTrackWord;')(); + const word = new Function(trackConsts + '\n' + fn(strip, 'stageTrackerWorkflowApprovalPending') + fn(strip, 'stageTrackerQueueAheadWord') + fn(strip, 'stageTrackerHiveOwnsRepair') + fn(strip, 'stageTrackerWaitingOnPerson') + fn(strip, 'stageTrackerTrackRunning') + fn(strip, 'stageTrackerTrackWord') + ';return stageTrackerTrackWord;')(); const ci = (state, extra = {}) => word({ head: 'h', ci_activity: { head: 'h', state, ...extra } }, 'ci', true); assert.equal(ci('passing', { checks_passed: 14, checks_total: 14 }), 'CI 14/14 passed'); assert.equal(ci('failing', { checks_passed: 11, checks_total: 14, checks_failed: 1, checks_failing: ['lint'] }), 'CI 11/14 · 1 failing (lint)'); @@ -779,7 +779,7 @@ test('#16484: count grammar — CI passed/total and Review done/total across eve assert.equal(ci('missing', { checks_passed: 13, checks_total: 14, blocker: 'test' }), 'CI 13/14 · test not reported'); assert.equal(ci('skipped', { checks_passed: 13, checks_total: 14, blocker: 'build' }), 'CI 13/14 · build skipped'); assert.equal(ci('unknown'), 'CI ?/? · no checks reported yet'); - assert.equal(ci('unknown', { checks_passed: 51, checks_total: 68 }), 'CI 51/68 · no verdict yet', 'unprotected base: head-wide counts without a required verdict'); + assert.equal(ci('unknown', { checks_passed: 51, checks_total: 68 }), 'CI 51/68 · running', 'unprotected base: an unfinished head-wide ring is still running (#16631)'); assert.equal(word({ head: 'h' }, 'ci', true), 'CI ?/? · no checks reported yet', 'no evidence at all in the current phase'); assert.equal(word({ head: 'h' }, 'ci', false), '', 'no evidence outside the current phase: not started, glyph alone'); assert.equal(word({ head: 'h', ci_activity: { head: 'old', state: 'passing', checks_passed: 14, checks_total: 14 } }, 'ci', true), 'CI ?/? · no checks reported yet', 'old-head evidence counts for nothing'); diff --git a/src/pkg/dashboard/stage_tracker_activity_test.go b/src/pkg/dashboard/stage_tracker_activity_test.go index 6c58028cc8..991dc436ac 100644 --- a/src/pkg/dashboard/stage_tracker_activity_test.go +++ b/src/pkg/dashboard/stage_tracker_activity_test.go @@ -1,6 +1,7 @@ package dashboard import ( + "fmt" "os/exec" "strings" "testing" @@ -23,7 +24,9 @@ func TestStageTrackerActivityRequiredCI(t *testing.T) { {"failure", "completed", "failure", "failing", true}, {"success", "completed", "success", "passing", true}, {"conditional skip", "completed", "skipped", "skipped", true}, - {"unknown required set", "completed", "failure", "unknown", false}, + // A queued neighbour keeps an ambiguous-required ring in motion + // (hivecommons/hive#16631). + {"unknown required set", "completed", "failure", "running", false}, } { t.Run(tc.name, func(t *testing.T) { pr := github.PullRequest{HeadSHA: "head", CIActivity: &github.PRCIActivity{ @@ -274,13 +277,17 @@ func TestStageTrackerActivityCIRetryAndMixedChecks(t *testing.T) { RequiredKnown: true, Required: []string{"build", "lint"}, Checks: []github.PRActivityCheck{ {Name: "build", State: "completed", Conclusion: "failure"}, {Name: "lint", State: "in_progress"}, }} - if got := stageTrackerCIActivity(pr, now); got.State != "failing" || !got.Active { + if got := stageTrackerCIActivity(pr, now); got.State != "running" || !got.Active || got.ChecksFailed != 1 || !strings.Contains(got.Caption, "1 failing") { t.Fatalf("failing required check hid simultaneous running CI: %+v", got) } pr.CIActivity.Checks = append(pr.CIActivity.Checks, github.PRActivityCheck{Name: "build", State: "completed", Conclusion: "success"}) - if got := stageTrackerCIActivity(pr, now); got.State != "unknown" { + if got := stageTrackerCIActivity(pr, now); got.State != "running" || got.ChecksPassed != 0 || got.ChecksFailed != 0 { t.Fatalf("ambiguous check apps manufactured success: %+v", got) } + pr.CIActivity.Checks[1] = github.PRActivityCheck{Name: "lint", State: "completed", Conclusion: "success"} + if got := stageTrackerCIActivity(pr, now); got.State != "unknown" { + t.Fatalf("ambiguous check apps manufactured success once settled: %+v", got) + } dispatch.Fixes = []review.PendingFix{{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA, Agent: "fixer", Dispatched: now}} status.Agents[1].AwaitingCI = true it := StageTrackerItem{Repo: pr.Repo, Kind: "pr", Number: pr.Number, Head: pr.HeadSHA, Stage: trackerNumberFixing} @@ -366,9 +373,27 @@ func TestStageTrackerActivityCICaptionsReadInPlainLanguage(t *testing.T) { t.Fatalf("%s: want %s %q (detail mentioning %q), got %+v", tc.name, tc.state, tc.want, tc.detailMention, got) } } - mixed := ci(done("build"), chk("lint", "completed", "failure"), chk("test", "in_progress", "")) - if got := stageTrackerCIActivity(mixed, now); got.Caption != `CI failing · "lint" red · other checks still running` { - t.Fatalf("mixed red+running caption: %+v", got) + // Motion leads a settled word: a ring that is not full is running, + // however red, unreported or ambiguous its neighbours (hivecommons/hive#16631). + motion := []struct { + name string + pr github.PullRequest + want string + }{ + {"red+running", ci(done("build"), chk("lint", "completed", "failure"), chk("test", "in_progress", "")), "CI running · 2/3 checks done · 1 failing"}, + {"missing+running", ci(done("build"), chk("lint", "in_progress", "")), "CI running · 1/3 checks done"}, + } + for _, tc := range motion { + got := stageTrackerCIActivity(tc.pr, now) + if got.State != "running" || got.Caption != tc.want || !got.Active { + t.Fatalf("%s: want running %q active, got %+v", tc.name, tc.want, got) + } + } + if got := stageTrackerCIActivity(ci(done("build"), done("lint"), done("lint"), chk("test", "queued", "")), now); got.State != "queued" || got.Caption != `CI queued · "test" waiting for a runner` { + t.Fatalf("ambiguous+queued: a waiting runner keeps the ring queued, not unknown: %+v", got) + } + if got := stageTrackerCIActivity(ci(done("build"), chk("lint", "completed", "failure"), done("test")), now); got.State != "failing" || got.Active { + t.Fatalf("settled red head must not read as running: %+v", got) } if got := stageTrackerCIActivity(github.PullRequest{Repo: pr.Repo, Number: pr.Number, HeadSHA: pr.HeadSHA}, now); got.Caption != "CI unknown · no check results observed for this head yet" || got.Detail == "" { t.Fatalf("no-evidence caption: %+v", got) @@ -422,8 +447,8 @@ func TestStageTrackerActivityCICheckCounts(t *testing.T) { {Name: "other-head", State: "completed", Conclusion: "success", Head: "old-head"}, } got = stageTrackerCIActivity(pr, now) - if got.State != "unknown" || got.ChecksTotal != 3 || got.ChecksPassed != 1 || got.ChecksFailed != 1 || strings.Join(got.ChecksFailing, ",") != "flaky" { - t.Fatalf("head-wide counts = %d/%d failed %d %v (state %s), want 1/3 failed 1 [flaky] unknown: a red run of a name stays red", got.ChecksPassed, got.ChecksTotal, got.ChecksFailed, got.ChecksFailing, got.State) + if got.State != "running" || got.ChecksTotal != 3 || got.ChecksPassed != 1 || got.ChecksFailed != 1 || strings.Join(got.ChecksFailing, ",") != "flaky" { + t.Fatalf("head-wide counts = %d/%d failed %d %v (state %s), want 1/3 failed 1 [flaky] running: a red run of a name stays red while the queued one keeps the ring in motion", got.ChecksPassed, got.ChecksTotal, got.ChecksFailed, got.ChecksFailing, got.State) } // No evidence for the head at all: no count ("CI ?/?"). pr.CIActivity.Checks = nil @@ -485,3 +510,41 @@ func TestStageTrackerActivityReviewPerspectiveCounts(t *testing.T) { t.Fatalf("old-head evidence leaked into counts: %d/%d", got.PerspectivesDone, got.PerspectivesTotal) } } + +func TestStageTrackerActivityCIPartialRingIsRunning(t *testing.T) { + now := time.Date(2026, 11, 4, 18, 0, 0, 0, time.UTC) + name := func(i int) string { return fmt.Sprintf("check-%02d", i) } + build := func(passed, pending int) github.PullRequest { + var required []string + var bindings []github.PRRequiredCheck + var checks []github.PRActivityCheck + for i := 0; i < passed+pending; i++ { + required = append(required, name(i)) + bindings = append(bindings, github.PRRequiredCheck{Name: name(i), AppKnown: true}) + if i < passed { + checks = append(checks, github.PRActivityCheck{Name: name(i), State: "completed", Conclusion: "success"}) + } else if i%2 == 0 { + checks = append(checks, github.PRActivityCheck{Name: name(i), State: "in_progress"}) + } + // Odd pending checks are not reported at all (a job that only + // starts after the shards finish), as on hivecommons/hive#16628. + } + return github.PullRequest{HeadSHA: "head", CIActivity: &github.PRCIActivity{ + Head: "head", Source: "github-check-runs", ObservedAt: &now, RequiredKnown: true, StatusesKnown: true, + Required: required, RequiredSource: "protection", RequiredChecks: bindings, Checks: checks}} + } + got := stageTrackerCIActivity(build(13, 6), now) + if got.State != "running" || !got.Active || got.ChecksPassed != 13 || got.ChecksTotal != 19 || got.Caption != "CI running · 13/19 checks done" { + t.Fatalf("13/19 with 6 pending must be an active running track: %+v", got) + } + full := stageTrackerCIActivity(build(19, 0), now) + if full.State != "passing" || full.Active || full.ChecksPassed != 19 || full.ChecksTotal != 19 { + t.Fatalf("19/19 is a complete green ring: %+v", full) + } + // Required set unknown: the head-wide count still reads motion. + loose := build(13, 6) + loose.CIActivity.RequiredKnown, loose.CIActivity.Required, loose.CIActivity.RequiredChecks = false, nil, nil + if got := stageTrackerCIActivity(loose, now); got.State != "running" || !got.Active || got.Caption != "CI running · 13/16 checks done" { + t.Fatalf("head-wide count with checks in progress must run: %+v", got) + } +} diff --git a/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js b/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js index 9775682398..c00b99dc73 100644 --- a/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js +++ b/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js @@ -229,3 +229,27 @@ test('#16539 shape: a queued swarm reads 0/5 and, as the stage\'s own track, is assert.doesNotMatch(c[5], /data-motion=/, 'queued is lit but still'); assert.equal(litCount(c.join('')), 1, 'the Review column is where the item is: the one lit chevron'); }); + +// hivecommons/hive#16631: a CI ring that is not full is a running ring. +// 13/19 with checks still pending is active with its count beside the +// running Review; only a complete 19/19 ring is the silent green glyph. +test('#16628 shape: CI 13/19 with pending checks + review in progress → both tracks active with words', () => { + const review = { head: 'abc1234def', state: 'reviewing', active: true, caption: 'Review 0/5 · in progress', perspectives_done: 0, perspectives_total: 5, source: 'dispatch', observed_at: seen }; + for (const state of ['running', 'unknown', 'queued']) { + const c = cells(redPR({ display_column: 50, stage: 50, + ci_activity: { head: 'abc1234def', state, caption: 'CI ' + state, checks_passed: 13, checks_total: 19, source: 'checks', observed_at: seen }, + review_activity: review })); + assert.match(c[4], /class="ham-seg ham-activity-track active ham-current"/, state + ': a part-filled ring is lit'); + assert.match(c[4], /CI 13\/19 · (running|queued) matches ? Number(a[k]) || 0 : 0; if (kind === 'ci') { const total = n('checks_total'); @@ -68,7 +68,9 @@ if (stageTrackerWorkflowApprovalPending(a) > 0) return count + ' · waiting on workflow approval' + (failing ? ' · ' + failing : ''); return count + ' · ' + (passed ? (blocker ? blocker + ' not reported' : 'not all reported') : 'no checks reported yet') + (failing ? ' · ' + failing : ''); } - default: return count + ' · ' + (total ? 'no verdict yet' : 'no checks reported yet'); + // An unfinished ring with no settled word is still running + // (hivecommons/hive#16631). + default: return count + ' · ' + (total ? (passed + failed < total ? 'running' + (failing ? ' · ' + failing : '') : 'no verdict yet') : 'no checks reported yet'); } } const total = n('perspectives_total'); @@ -222,7 +224,19 @@ if (!a || !item.head || a.head !== item.head) return false; if (stageTrackerWaitingOnPerson(item)) return false; const moving = kind === 'ci' ? ['running', 'queued'] : ['reviewing', 'adjudicating', 'assigned']; - return !!(a.active || moving.includes(a.state)); + if (a.active || moving.includes(a.state)) return true; + // A CI ring that is not full is a running ring: checks counted on + // the head but not yet passed or failed are still in motion unless + // the track has settled on a word of its own (a finding, a pass, a + // skip, an unreported required check, a person's decision) + // (hivecommons/hive#16631). + if (kind !== 'ci') return false; + // Inferred motion only; a row parked on a person's decision is not + // waiting on checks, whatever its cached counts say. + if ((item.decision_needed && item.decision_needed.question) || item.human_attention) return false; + const total = Number(a.checks_total) || 0, done = (Number(a.checks_passed) || 0) + (Number(a.checks_failed) || 0); + const settledWords = ['passing', 'failing', 'skipped', 'missing', 'human_decision']; + return total > 0 && done < total && !settledWords.includes(a.state); } // Evidence is supplied independently by the backend. A native 050 label diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index ba8b3295a2..575abb0379 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -17919,7 +17919,7 @@

Where to get help

const a = item && item[kind + '_activity']; const matches = !!(a && item.head && a.head === item.head); const state = matches ? a.state || 'unknown' : 'unknown'; - if (state === 'unknown' && !current) return ''; + if (state === 'unknown' && !current && !stageTrackerTrackRunning(item, kind)) return ''; const n = k => matches ? Number(a[k]) || 0 : 0; if (kind === 'ci') { const total = n('checks_total'); @@ -17939,7 +17939,9 @@

Where to get help

if (stageTrackerWorkflowApprovalPending(a) > 0) return count + ' · waiting on workflow approval' + (failing ? ' · ' + failing : ''); return count + ' · ' + (passed ? (blocker ? blocker + ' not reported' : 'not all reported') : 'no checks reported yet') + (failing ? ' · ' + failing : ''); } - default: return count + ' · ' + (total ? 'no verdict yet' : 'no checks reported yet'); + // An unfinished ring with no settled word is still running + // (hivecommons/hive#16631). + default: return count + ' · ' + (total ? (passed + failed < total ? 'running' + (failing ? ' · ' + failing : '') : 'no verdict yet') : 'no checks reported yet'); } } const total = n('perspectives_total'); @@ -18093,7 +18095,19 @@

Where to get help

if (!a || !item.head || a.head !== item.head) return false; if (stageTrackerWaitingOnPerson(item)) return false; const moving = kind === 'ci' ? ['running', 'queued'] : ['reviewing', 'adjudicating', 'assigned']; - return !!(a.active || moving.includes(a.state)); + if (a.active || moving.includes(a.state)) return true; + // A CI ring that is not full is a running ring: checks counted on + // the head but not yet passed or failed are still in motion unless + // the track has settled on a word of its own (a finding, a pass, a + // skip, an unreported required check, a person's decision) + // (hivecommons/hive#16631). + if (kind !== 'ci') return false; + // Inferred motion only; a row parked on a person's decision is not + // waiting on checks, whatever its cached counts say. + if ((item.decision_needed && item.decision_needed.question) || item.human_attention) return false; + const total = Number(a.checks_total) || 0, done = (Number(a.checks_passed) || 0) + (Number(a.checks_failed) || 0); + const settledWords = ['passing', 'failing', 'skipped', 'missing', 'human_decision']; + return total > 0 && done < total && !settledWords.includes(a.state); } // Evidence is supplied independently by the backend. A native 050 label From 73ccd4b4ffb21d9bf49f0490a7e5e208298896ac Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 13:37:16 -0500 Subject: [PATCH 03/24] =?UTF-8?q?=F0=9F=90=9B=20Activity=20Monitor:=20re-r?= =?UTF-8?q?eview=20waits=20on=20the=20hive=20reviewer;=20CI=20from=20a=20f?= =?UTF-8?q?ull=20check=20list=20(#16636)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A pushed head whose checks are green and which carries no findings or unrebased conflict owes nothing to its author: the re-review is the hive reviewer's. The row says so (rework.owed_by = hive-reviewer / author), the pill reads 'waiting on 🐝 hive reviewer · re-review of ', and the Review chevron is the lit one with CI an icon-only green ring. The stale 'CI 7/11 · test not reported' caption came from the GraphQL PR batch: statusCheckRollup.contexts(first: 50) had no totalCount and a truncated page was cached as the head's complete listing, so the required aggregates past the page read as never reported. The query now asks for 100 with totalCount, and a truncated rollup is treated as no listing so enrichPRCI falls back to the paginated REST check-runs. Fixes #16635 Signed-off-by: Andrew Anderson Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-rereview-pill-attribution.md | 1 + .../dashboard/stage_tracker_activity.test.js | 32 +++++++-- src/pkg/dashboard/stage_tracker_build.go | 1 + .../dashboard/stage_tracker_presence.test.js | 47 +++++++++++- src/pkg/dashboard/stage_tracker_rework.go | 45 ++++++++++++ .../dashboard/stage_tracker_rework_test.go | 71 ++++++++++++++++++- .../static-src/js/tracker-row-strip.js | 22 ++++-- .../dashboard/static-src/js/tracker-words.js | 38 +++++++++- src/pkg/dashboard/static/index.html | 60 ++++++++++++++-- src/pkg/github/pr_batch_graphql.go | 27 ++++++- .../github/pr_batch_graphql_status_test.go | 30 ++++++++ 11 files changed, 351 insertions(+), 23 deletions(-) create mode 100644 changelog.d/fixed-rereview-pill-attribution.md 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 71dd40da16..2edcadd8e0 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 e363e691b5..2c057d4b09 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. @@ -79,7 +88,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'; @@ -100,7 +112,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'); } } @@ -209,7 +221,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 575abb0379..67eca47315 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. @@ -17950,7 +17993,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'; @@ -17971,7 +18017,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'); } } @@ -18080,7 +18126,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)) + } +} From 09c6d46df8811bec67ff71cabc3384b67f2b14e0 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 13:45:44 -0500 Subject: [PATCH 04/24] fix(dashboard): place the base-branch pill beside the repo chip (#16621) The Activity Monitor's base pill (v5, main) moves from the PR column's trailing cluster to the row head, right after the repo chip and before the issue #N, styled as a muted sibling of that chip. Issue rows show the primary linked PR's base, PR rows and sub-rows their own; rows with no PR show nothing. The pill tooltip names the PR it describes. Fixes #16620 Signed-off-by: Andrew Anderson --- ...activity-monitor-base-pill-by-repo-chip.md | 1 + .../stage_tracker_header_spans.test.js | 4 +-- .../stage_tracker_human_attention.test.js | 2 +- .../dashboard/stage_tracker_motion_test.go | 2 ++ .../stage_tracker_preparation_visual.test.js | 2 +- .../stage_tracker_repo_grouping_test.go | 1 + .../stage_tracker_single_note.test.js | 2 +- .../stage_tracker_ui_prelude_test.go | 1 + .../dashboard/stage_tracker_ui_rows_test.go | 23 +++++++++---- src/pkg/dashboard/static-src/css/tracker.css | 2 ++ .../static-src/js/tracker-row-layout.js | 19 ++++++++--- .../static-src/js/tracker-row-render.js | 12 ++++--- src/pkg/dashboard/static/index.html | 33 ++++++++++++++----- 13 files changed, 74 insertions(+), 30 deletions(-) create mode 100644 changelog.d/changed-activity-monitor-base-pill-by-repo-chip.md diff --git a/changelog.d/changed-activity-monitor-base-pill-by-repo-chip.md b/changelog.d/changed-activity-monitor-base-pill-by-repo-chip.md new file mode 100644 index 0000000000..59402ac43c --- /dev/null +++ b/changelog.d/changed-activity-monitor-base-pill-by-repo-chip.md @@ -0,0 +1 @@ +- Activity Monitor rows now draw a PR's base-branch pill (`v5`, `main`) right after the repo chip at the head of the row, before the issue number, instead of in the right-hand modifier cluster; the pill names its PR on hover ("PR #N targets v5") and rows with no linked PR show none. ([#16620](https://github.com/hivecommons/hive/issues/16620)) diff --git a/src/pkg/dashboard/stage_tracker_header_spans.test.js b/src/pkg/dashboard/stage_tracker_header_spans.test.js index 2bdc9a9dcc..7994a82e8e 100644 --- a/src/pkg/dashboard/stage_tracker_header_spans.test.js +++ b/src/pkg/dashboard/stage_tracker_header_spans.test.js @@ -28,7 +28,7 @@ function load() { stageTrackerIcon: (kind, cls) => ``, stageTrackerRepoChipHtml: () => '', stageTrackerTooltip: () => 'tooltip', - stageTrackerPRPillsHtml: ref => `${ref}base v5`, + stageTrackerPRPillsHtml: ref => `${ref}`, stageTrackerActedBadgeHtml: () => '', stageTrackerChipsHtml: () => chips, stageTrackerMoveAttrs: () => '', @@ -42,7 +42,7 @@ function load() { vm.runInContext(pick(new RegExp('const ' + name + ' = [^\\n]*'), name), ctx); } for (const name of ['stageTrackerHeadColsHtml', 'stageTrackerHeaderHtml', 'stageTrackerRowHtml', 'stageTrackerSubRowHtml', - 'stageTrackerPRRef', 'stageTrackerPRIssueSlot', 'stageTrackerTitleHtml', 'stageTrackerSplitTitleTag']) { + 'stageTrackerPRRef', 'stageTrackerPRIssueSlot', 'stageTrackerTitleHtml', 'stageTrackerSplitTitleTag', 'stageTrackerBasePillHtml']) { vm.runInContext(fn(name), ctx); } return ctx; diff --git a/src/pkg/dashboard/stage_tracker_human_attention.test.js b/src/pkg/dashboard/stage_tracker_human_attention.test.js index 31a3812cf3..14808199cd 100644 --- a/src/pkg/dashboard/stage_tracker_human_attention.test.js +++ b/src/pkg/dashboard/stage_tracker_human_attention.test.js @@ -38,7 +38,7 @@ function load() { }); for (const name of ['stageTrackerLinkedSuperseder', 'stageTrackerLinkedSupersededGone', 'stageTrackerLinkedSupersededText', 'stageTrackerLinkedSupersededTip']) vm.runInContext(fn('tracker-words-gate', name), c); for (const name of ['stageTrackerItemKey', 'stageTrackerPRKey', 'stageTrackerRowPRKeys']) vm.runInContext(fn('tracker-merged', name), c); - for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml']) vm.runInContext(fn('tracker-row-layout', name), c); + for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml', 'stageTrackerBasePillHtml']) vm.runInContext(fn('tracker-row-layout', name), c); vm.runInContext(fn('tracker-row-render', 'stageTrackerRowHtml'), c); vm.runInContext(fn('tracker-filter', 'stageTrackerPRIssueSlot'), c); vm.runInContext(source('tracker-human-attention'), c); diff --git a/src/pkg/dashboard/stage_tracker_motion_test.go b/src/pkg/dashboard/stage_tracker_motion_test.go index 4303ddbc9a..2ff3753df8 100644 --- a/src/pkg/dashboard/stage_tracker_motion_test.go +++ b/src/pkg/dashboard/stage_tracker_motion_test.go @@ -456,6 +456,7 @@ func TestStageTrackerMotionRowStamp(t *testing.T) { stageTrackerActedJS(t, html), jsFunc(t, html, "stageTrackerSubRowHtml"), jsFunc(t, html, "stageTrackerPRPillsHtml"), + jsFunc(t, html, "stageTrackerBasePillHtml"), jsFunc(t, html, "stageTrackerLinkedPRItem"), jsFunc(t, html, "stageTrackerLinkedPROpen"), jsFunc(t, html, "stageTrackerNestedOpenPRs"), @@ -590,6 +591,7 @@ func TestStageTrackerMotionPreviewSample(t *testing.T) { stageTrackerActedJS(t, html), jsFunc(t, html, "stageTrackerSubRowHtml"), jsFunc(t, html, "stageTrackerPRPillsHtml"), + jsFunc(t, html, "stageTrackerBasePillHtml"), jsFunc(t, html, "stageTrackerLinkedPRItem"), jsFunc(t, html, "stageTrackerLinkedPROpen"), jsFunc(t, html, "stageTrackerNestedOpenPRs"), diff --git a/src/pkg/dashboard/stage_tracker_preparation_visual.test.js b/src/pkg/dashboard/stage_tracker_preparation_visual.test.js index 5fabcc1322..f7a0b9a932 100644 --- a/src/pkg/dashboard/stage_tracker_preparation_visual.test.js +++ b/src/pkg/dashboard/stage_tracker_preparation_visual.test.js @@ -52,7 +52,7 @@ function load() { for (const name of ['stageTrackerTrainIconHtml', 'stageTrackerTrainAccentClass', 'stageTrackerOrdinal']) vm.runInContext(fn('tracker-words-core', name), ctx); for (const name of ['stageTrackerLinkedSuperseder', 'stageTrackerLinkedSupersededGone', 'stageTrackerLinkedSupersededText', 'stageTrackerLinkedSupersededTip']) vm.runInContext(fn('tracker-words-gate', name), ctx); for (const name of ['stageTrackerPRKey', 'stageTrackerItemKey', 'stageTrackerRowPRKeys']) vm.runInContext(fn('tracker-merged', name), ctx); - for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerAdoptOrphanPRs', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml']) vm.runInContext(fn('tracker-row-layout', name), ctx); + for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerAdoptOrphanPRs', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml', 'stageTrackerBasePillHtml']) vm.runInContext(fn('tracker-row-layout', name), ctx); vm.runInContext(fn('tracker-row-render', 'stageTrackerRowHtml'), ctx); for (const name of ['stageTrackerPreparationWord', 'stageTrackerPreparationAge', 'stageTrackerPreparationChipHtml']) vm.runInContext(fn('tracker-queue', name), ctx); for (const name of ['stageTrackerSort', 'stageTrackerPage', 'stageTrackerPRIssueSlot']) vm.runInContext(fn('tracker-filter', name), ctx); diff --git a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go index be70f59325..6ba3f52f2c 100644 --- a/src/pkg/dashboard/stage_tracker_repo_grouping_test.go +++ b/src/pkg/dashboard/stage_tracker_repo_grouping_test.go @@ -172,6 +172,7 @@ func stageTrackerRepoGroupingHarness(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerSinceHtml"), jsFunc(t, html, "stageTrackerSubRowHtml"), jsFunc(t, html, "stageTrackerPRPillsHtml"), + jsFunc(t, html, "stageTrackerBasePillHtml"), jsFunc(t, html, "stageTrackerLinkedPRItem"), jsFunc(t, html, "stageTrackerLinkedPROpen"), jsFunc(t, html, "stageTrackerNestedOpenPRs"), diff --git a/src/pkg/dashboard/stage_tracker_single_note.test.js b/src/pkg/dashboard/stage_tracker_single_note.test.js index 408c03f461..81c541de56 100644 --- a/src/pkg/dashboard/stage_tracker_single_note.test.js +++ b/src/pkg/dashboard/stage_tracker_single_note.test.js @@ -53,7 +53,7 @@ function load() { vm.runInContext(fn('tracker-words-stage', 'stageTrackerStageName'), c); for (const name of ['stageTrackerLinkedSuperseder', 'stageTrackerLinkedSupersededGone', 'stageTrackerLinkedSupersededText', 'stageTrackerLinkedSupersededTip']) vm.runInContext(fn('tracker-words-gate', name), c); for (const name of ['stageTrackerItemKey', 'stageTrackerPRKey', 'stageTrackerRowPRKeys']) vm.runInContext(fn('tracker-merged', name), c); - for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml']) vm.runInContext(fn('tracker-row-layout', name), c); + for (const name of ['stageTrackerLinkedPRItem', 'stageTrackerLinkedPROpen', 'stageTrackerLinkedDrawnHere', 'stageTrackerLinkedSorted', 'stageTrackerHeadColsHtml', 'stageTrackerSubRowHtml', 'stageTrackerBasePillHtml']) vm.runInContext(fn('tracker-row-layout', name), c); vm.runInContext(fn('tracker-row-render', 'stageTrackerRowHtml'), c); vm.runInContext(fn('tracker-filter', 'stageTrackerPRIssueSlot'), c); vm.runInContext(source('tracker-motion'), c); diff --git a/src/pkg/dashboard/stage_tracker_ui_prelude_test.go b/src/pkg/dashboard/stage_tracker_ui_prelude_test.go index 0bd1189921..039227d542 100644 --- a/src/pkg/dashboard/stage_tracker_ui_prelude_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_prelude_test.go @@ -134,6 +134,7 @@ func stageTrackerRowsPreludeJS(t *testing.T, html string) string { jsFunc(t, html, "stageTrackerSinceHtml"), jsFunc(t, html, "stageTrackerSubRowHtml"), jsFunc(t, html, "stageTrackerPRPillsHtml"), + jsFunc(t, html, "stageTrackerBasePillHtml"), jsFunc(t, html, "stageTrackerAgoText"), jsConstBlock(t, html, "STAGE_TRACKER_LINEAGE_REASON_TIP"), jsFunc(t, html, "stageTrackerLineageText"), diff --git a/src/pkg/dashboard/stage_tracker_ui_rows_test.go b/src/pkg/dashboard/stage_tracker_ui_rows_test.go index 6797a4091d..6a23eb6605 100644 --- a/src/pkg/dashboard/stage_tracker_ui_rows_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_rows_test.go @@ -461,7 +461,15 @@ assert.ok(!row.includes('ham-issue-refs-chip'), 'closing link draws no refs chip row = stageTrackerRowHtml({ repo: 'acme/console', number: 9, kind: 'issue', title: 'Tracker', stage: 40, claim_reference: true, is_tracker: true, children: { total: 3, completed: 1 }, linked_prs: [{ number: 203, title: 'Draft work', stage: 10, base_ref: 'v6' }] }, stages, ctx); assert.ok(row.includes('refs'), 'issue refs chip: ' + row); assert.ok(row.includes('tracker 1/3'), 'tracker progress: ' + row); -assert.ok(row.includes('v6'), 'covering PR base: ' + row); +// The base pill sits at the row head by the repo chip, before the issue #N, +// with the PR it describes in its tooltip — not in the PR column's cluster. +assert.ok(row.includes('v6'), 'covering PR base pill: ' + row); +assert.ok(row.indexOf('ham-base-pill') < row.indexOf('>#9'), 'base pill precedes the issue ref: ' + row); +assert.ok(!row.includes('v6'), 'base no longer a right-hand badge: ' + row); +assert.ok(!row.slice(row.indexOf('ham-head-pr'), row.indexOf('ham-since')).includes('>v6<'), 'base absent from the PR column: ' + row); +// No PR, no pill; a PR row carries its own base. +assert.ok(!stageTrackerRowHtml({ repo: 'acme/console', number: 10, kind: 'issue', title: 'Bare', stage: 10 }, stages, ctx).includes('ham-base-pill'), 'no PR → no base pill'); +assert.ok(stageTrackerRowHtml({ repo: 'acme/console', number: 204, kind: 'pr', title: 'Own row', stage: 60, base_ref: 'v5' }, stages, ctx).includes('v5'), 'PR row base pill'); // 040 shares the PR in progress column with 030; the chevron tooltip names the real stage. row = stageTrackerRowHtml({ repo: 'acme/console', number: 9, kind: 'issue', title: 'Ordering drifts', stage: 40, linked_prs: [{ number: 103, title: 'Backport', author_kind: 'clanker', stage: 30 }, { number: 102, title: 'Fix it', url: 'u', author_kind: 'human', stage: 70, stage_since: new Date(now - 3600000).toISOString(), modifiers: ['needs-rebase'], caption: 'Rebasing onto main' }] }, stages, ctx); @@ -493,23 +501,24 @@ sr = subs(row); const cell = (head.match(/
  • ]*>([\s\S]*?)<\/li>/) || [])[1] || ''; assert.ok(cell, 'sub-row header has one PR cell: ' + head); assert.ok(!/v5')]; - assert.ok(order.every((i, k) => i >= 0 && (k === 0 || i > order[k - 1])), 'connector, PR link, lineage chip, base pill in that order as siblings: ' + cell); - assert.ok(cell.indexOf('v5') > cell.indexOf('', cell.indexOf('v5'), cell.indexOf(' i >= 0 && (k === 0 || i > order[k - 1])), 'connector, base pill, PR link, lineage chip in that order as siblings: ' + cell); + assert.ok(!cell.includes('v5'), 'the base is no longer a trailing badge: ' + cell); assert.ok(/]*title="docs: remove duplicate README run routes · /.test(cell), 'the PR link hover starts with the full title: ' + cell); assert.ok(!head.includes('ham-lineage" title') || head.indexOf('ham-lineage') < head.indexOf(''), 'the lineage chip rides the PR cell ahead of the modifier chips, not the chip toolbar: ' + head); assert.strictEqual((head.match(/ham-lineage/g) || []).length, 1, 'the lineage chip is drawn once'); } // The same order on an issue row with a single covering PR: lineage chip -// before the base pill, both after the PR link. +// after the PR link; the base pill leads the row by the repo chip instead. row = stageTrackerRowHtml({ repo: 'acme/console', number: 9, kind: 'issue', title: 'One PR', stage: 40, linked_prs: [{ number: 15343, title: 'T', stage: 50, base_ref: 'v5', lineage: { kind: 'adopted', from_number: 15226 } }] }, stages, ctx); { const cell = prCell(row); - assert.ok(cell.indexOf('v5'), 'PR link, lineage, base pill: ' + cell); + assert.ok(cell.indexOf('v5'), 'PR link, lineage; no base pill in the PR cell: ' + cell); + assert.ok(row.indexOf('v5') < row.indexOf('>#9'), 'base pill ahead of the issue ref: ' + row); } // An incomplete lineage has no chip and must not add an extra separator. row = stageTrackerRowHtml({ repo: 'acme/console', number: 9, kind: 'issue', title: 'Empty lineage', stage: 40, linked_prs: [{ number: 15343, title: 'T', stage: 50, base_ref: 'v5', lineage: { kind: 'adopted' } }] }, stages, ctx); -assert.match(prCell(row), /<\/a> v5<\/span>/, 'empty lineage leaves one separator before the base pill'); +assert.match(prCell(row), /<\/a>/, 'empty lineage leaves no stray separator after the PR link'); assert.ok(!prCell(row).includes('ham-lineage'), 'empty lineage renders no chip'); row = stageTrackerRowHtml({ repo: 'acme/console', number: 10, kind: 'issue', stage: 30 }, stages, ctx); assert.deepStrictEqual(segStates(row), [D, D, D, 'active', T, T, 'todo cap'], 'kick running, no PR yet: the issue lights PR in progress and draws the steps ahead'); diff --git a/src/pkg/dashboard/static-src/css/tracker.css b/src/pkg/dashboard/static-src/css/tracker.css index 0e16ece3c5..cc2af4a9ee 100644 --- a/src/pkg/dashboard/static-src/css/tracker.css +++ b/src/pkg/dashboard/static-src/css/tracker.css @@ -178,6 +178,8 @@ .ham-repo-tint-4 { --ham-repo-tint: var(--ham-repo-tint-4); } .ham-repo-tint-5 { --ham-repo-tint: var(--ham-repo-tint-5); } .ham-repo-chip.ham-repo-primary { --ham-repo-tint: var(--text-muted); } + /* The PR's base branch: same height and type as the repo chip it follows, muted border, no tint. */ + .ham-base-pill { flex: 0 0 auto; display: inline-block; font: inherit; font-family: var(--font-mono); font-size: var(--fs-2xs); line-height: 1.5; padding: 0 var(--sp-2); border-radius: var(--r-sm); border: var(--line-width) solid var(--line-subtle); color: var(--text-faint); white-space: nowrap; max-width: 9em; overflow: hidden; text-overflow: ellipsis; vertical-align: baseline; } .ham-pr-line { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; max-width: 100%; overflow: hidden; } /* Group-by-repo header row: sticky under the column header while its rows scroll, caret toggle, chip, owner/repo, counts, and a mini diff --git a/src/pkg/dashboard/static-src/js/tracker-row-layout.js b/src/pkg/dashboard/static-src/js/tracker-row-layout.js index b4a6b966a6..b9180ec911 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-layout.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-layout.js @@ -219,9 +219,18 @@ ctx.rows = typeof _stageTrackerRows !== 'undefined' ? _stageTrackerRows : null; return stageTrackerLeadActionHtml(item, ctx, subRows); } - // PR link, then the lineage chip (null = none), then the base pill. - function stageTrackerPRPillsHtml(ref, lineage, baseRef) { - return ref + (lineage == null ? '' : ' ' + lineage) + (baseRef ? ` ${esc(baseRef)}` : ''); + // PR link, then the lineage chip (null = none). The base pill sits by + // the repo chip at the row's head (stageTrackerBasePillHtml), not here. + function stageTrackerPRPillsHtml(ref, lineage) { + return ref + (lineage == null ? '' : ' ' + lineage); + } + // Pure: the PR's base branch as a quiet sibling of the repo chip — + // `[hive][v5] #16603 …` — so the target reads with the repo, not in the + // right-hand modifier cluster. '' when the row has no PR (or no base). + function stageTrackerBasePillHtml(baseRef, prNumber) { + if (!baseRef) return ''; + const tip = (Number(prNumber) ? 'PR #' + Number(prNumber) + ' targets ' : 'Targets ') + baseRef; + return `${esc(baseRef)}`; } function stageTrackerSubRowHtml(lp, issue, stages, nowMs, ctx) { const pr = stageTrackerLinkedPRItem(issue, lp); @@ -233,9 +242,9 @@ // A superseded original wears neither pill — it closes as superseded, // not as the closer of anything. const lineage = superseded ? '' : ((typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(pr, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(pr, nowMs) : '')); - const chip = ctx && ctx.repoChips ? stageTrackerRepoChipHtml(pr.repo, ctx) : ''; + const chip = (ctx && ctx.repoChips ? stageTrackerRepoChipHtml(pr.repo, ctx) : '') + stageTrackerBasePillHtml(lp.base_ref, pr.number); if (chip) ref = `${chip}${ref}`; - ref = stageTrackerPRPillsHtml(ref, !superseded && typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null), lp.base_ref); + ref = stageTrackerPRPillsHtml(ref, !superseded && typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null)); ref = STAGE_TRACKER_LINKED_GLYPH + ref; if (superseded) { // The adopted original: one muted line, no chevron track, no row diff --git a/src/pkg/dashboard/static-src/js/tracker-row-render.js b/src/pkg/dashboard/static-src/js/tracker-row-render.js index 8a24fb30e1..ea32ee88a7 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-render.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-render.js @@ -93,9 +93,11 @@ const nowMs = Number(ctx.nowMs) || Date.now(); const isIssue = item.kind === 'issue'; const title = item.title || ''; - let prRefs = [], shown = item, range = null, subs = '', subRows = null, prTargetKey = ''; + let prRefs = [], shown = item, range = null, subs = '', subRows = null, prTargetKey = '', basePill = ''; if (isIssue) { const linked = stageTrackerLinkedSorted(item, stages); + // The primary (first-sorted) PR's base; an issue with no PR shows none. + if (linked.length) basePill = stageTrackerBasePillHtml(linked[0].base_ref, linked[0].number); if (linked.length === 1) { // One covering PR: a single entry whose strip the PR's stage drives. const lp = linked[0]; @@ -103,7 +105,7 @@ prTargetKey = stageTrackerItemKey(pr); const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); const lineage = (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : ''); - prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null), lp.base_ref)]; + prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null))]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, preparation: lp.preparation || null, ci_activity: lp.ci_activity || null, review_activity: lp.review_activity || null, code_activity: lp.code_activity || null, display_column: lp.display_column || 0, terminal_merge: !!lp.terminal_merge, merged_by: lp.merged_by || '', @@ -129,8 +131,10 @@ // as one (hivecommons/hive#15232) — and the PR stays in the PR column // rather than taking the issue slot. A not-planned close adds a chip // saying the PR may be moot. - // The repo chip (when on) leads the row, before the issue slot's #N. - const chip = ctx.repoChips ? stageTrackerRepoChipHtml(item.repo, ctx) : ''; + // The repo chip (when on) leads the row, before the issue slot's #N; + // the PR's base pill follows it as a quieter sibling. + if (!isIssue) basePill = stageTrackerBasePillHtml(item.base_ref, item.number); + const chip = (ctx.repoChips ? stageTrackerRepoChipHtml(item.repo, ctx) : '') + basePill; let leadHtml; if (isIssue) { leadHtml = `
    diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 67eca47315..c6d55193e0 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -1518,6 +1518,8 @@ .ham-repo-tint-4 { --ham-repo-tint: var(--ham-repo-tint-4); } .ham-repo-tint-5 { --ham-repo-tint: var(--ham-repo-tint-5); } .ham-repo-chip.ham-repo-primary { --ham-repo-tint: var(--text-muted); } + /* The PR's base branch: same height and type as the repo chip it follows, muted border, no tint. */ + .ham-base-pill { flex: 0 0 auto; display: inline-block; font: inherit; font-family: var(--font-mono); font-size: var(--fs-2xs); line-height: 1.5; padding: 0 var(--sp-2); border-radius: var(--r-sm); border: var(--line-width) solid var(--line-subtle); color: var(--text-faint); white-space: nowrap; max-width: 9em; overflow: hidden; text-overflow: ellipsis; vertical-align: baseline; } .ham-pr-line { display: inline-flex; align-items: center; gap: var(--sp-2); min-width: 0; max-width: 100%; overflow: hidden; } /* Group-by-repo header row: sticky under the column header while its rows scroll, caret toggle, chip, owner/repo, counts, and a mini @@ -19424,9 +19426,18 @@

    Where to get help

    ctx.rows = typeof _stageTrackerRows !== 'undefined' ? _stageTrackerRows : null; return stageTrackerLeadActionHtml(item, ctx, subRows); } - // PR link, then the lineage chip (null = none), then the base pill. - function stageTrackerPRPillsHtml(ref, lineage, baseRef) { - return ref + (lineage == null ? '' : ' ' + lineage) + (baseRef ? ` ${esc(baseRef)}` : ''); + // PR link, then the lineage chip (null = none). The base pill sits by + // the repo chip at the row's head (stageTrackerBasePillHtml), not here. + function stageTrackerPRPillsHtml(ref, lineage) { + return ref + (lineage == null ? '' : ' ' + lineage); + } + // Pure: the PR's base branch as a quiet sibling of the repo chip — + // `[hive][v5] #16603 …` — so the target reads with the repo, not in the + // right-hand modifier cluster. '' when the row has no PR (or no base). + function stageTrackerBasePillHtml(baseRef, prNumber) { + if (!baseRef) return ''; + const tip = (Number(prNumber) ? 'PR #' + Number(prNumber) + ' targets ' : 'Targets ') + baseRef; + return `${esc(baseRef)}`; } function stageTrackerSubRowHtml(lp, issue, stages, nowMs, ctx) { const pr = stageTrackerLinkedPRItem(issue, lp); @@ -19438,9 +19449,9 @@

    Where to get help

    // A superseded original wears neither pill — it closes as superseded, // not as the closer of anything. const lineage = superseded ? '' : ((typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(pr, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(pr, nowMs) : '')); - const chip = ctx && ctx.repoChips ? stageTrackerRepoChipHtml(pr.repo, ctx) : ''; + const chip = (ctx && ctx.repoChips ? stageTrackerRepoChipHtml(pr.repo, ctx) : '') + stageTrackerBasePillHtml(lp.base_ref, pr.number); if (chip) ref = `${chip}${ref}`; - ref = stageTrackerPRPillsHtml(ref, !superseded && typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null), lp.base_ref); + ref = stageTrackerPRPillsHtml(ref, !superseded && typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null)); ref = STAGE_TRACKER_LINKED_GLYPH + ref; if (superseded) { // The adopted original: one muted line, no chevron track, no row @@ -19697,9 +19708,11 @@

    Where to get help

    const nowMs = Number(ctx.nowMs) || Date.now(); const isIssue = item.kind === 'issue'; const title = item.title || ''; - let prRefs = [], shown = item, range = null, subs = '', subRows = null, prTargetKey = ''; + let prRefs = [], shown = item, range = null, subs = '', subRows = null, prTargetKey = '', basePill = ''; if (isIssue) { const linked = stageTrackerLinkedSorted(item, stages); + // The primary (first-sorted) PR's base; an issue with no PR shows none. + if (linked.length) basePill = stageTrackerBasePillHtml(linked[0].base_ref, linked[0].number); if (linked.length === 1) { // One covering PR: a single entry whose strip the PR's stage drives. const lp = linked[0]; @@ -19707,7 +19720,7 @@

    Where to get help

    prTargetKey = stageTrackerItemKey(pr); const who = (lp.author_kind || 'hive') + (lp.author ? ' · @' + lp.author : ''); const lineage = (lp.lineage && typeof stageTrackerLineageChipHtml === 'function' ? stageTrackerLineageChipHtml(lp, nowMs) : '') || (typeof stageTrackerAdoptedFromChipHtml === 'function' ? stageTrackerAdoptedFromChipHtml(lp, nowMs) : ''); - prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null), lp.base_ref)]; + prRefs = [STAGE_TRACKER_LINKED_GLYPH + stageTrackerPRPillsHtml(stageTrackerPRRef(lp.number, lp.url, lp.author_kind || '', lp.author, lp.title, (lp.title ? lp.title + '\n' : '') + 'Author: ' + who + ' · ' + stageTrackerLinkedTip(item, lp.number, ctx)), typeof stageTrackerLinkedChipsHtml === 'function' ? stageTrackerLinkedChipsHtml(lp, lineage) : (lineage || null))]; shown = Object.assign({}, item, { via_pr: true, stage: stageTrackerLeadStage(lp), stage_since: lp.stage_since || item.stage_since, modifiers: lp.modifiers || item.modifiers, deferred_modifiers: lp.deferred_modifiers || item.deferred_modifiers || [], caption: lp.caption || item.caption, reason: lp.reason || item.reason, preparation: lp.preparation || null, ci_activity: lp.ci_activity || null, review_activity: lp.review_activity || null, code_activity: lp.code_activity || null, display_column: lp.display_column || 0, terminal_merge: !!lp.terminal_merge, merged_by: lp.merged_by || '', @@ -19733,8 +19746,10 @@

    Where to get help

    // as one (hivecommons/hive#15232) — and the PR stays in the PR column // rather than taking the issue slot. A not-planned close adds a chip // saying the PR may be moot. - // The repo chip (when on) leads the row, before the issue slot's #N. - const chip = ctx.repoChips ? stageTrackerRepoChipHtml(item.repo, ctx) : ''; + // The repo chip (when on) leads the row, before the issue slot's #N; + // the PR's base pill follows it as a quieter sibling. + if (!isIssue) basePill = stageTrackerBasePillHtml(item.base_ref, item.number); + const chip = (ctx.repoChips ? stageTrackerRepoChipHtml(item.repo, ctx) : '') + basePill; let leadHtml; if (isIssue) { leadHtml = `
    From f20a2286e69721bcf641adfff8cfc99c7e01ae89 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 13:52:36 -0500 Subject: [PATCH 05/24] =?UTF-8?q?=F0=9F=90=9B=20ACMM:=20recognize=20instal?= =?UTF-8?q?l=20and=20boot=20E2E=20workflows=20(#16640)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(acmm): recognize install and boot E2E workflows Add basename glob matching against GitHub directory listings while retaining existing web and E2E directory alternatives. Cover real install/boot names, unrelated workflows, invalid globs, directory lookalikes, and directory-cache fallback behavior. AI-assisted implementation prepared under James Reilly’s authenticated account. No independent human review or approval is claimed. References tuna-os/tromso#275; deployment of an evaluator release remains required. Signed-off-by: James Reilly Signed-off-by: Andrew Anderson * fix(acmm): cache missing parent directory for glob lookups Addresses the reviewer note on #16268: when the parent directory of a glob pattern does not exist, cache the empty listing so the remaining glob patterns for the same parent do not each issue another 404 lookup. Signed-off-by: Andrew Anderson --------- Signed-off-by: James Reilly Signed-off-by: Andrew Anderson Co-authored-by: James Reilly --- changelog.d/fixed-acmm-install-e2e.md | 1 + src/docs/acmm-policy-matrix.md | 21 ++++ src/pkg/dashboard/acmm_criteria.go | 4 +- src/pkg/dashboard/api_acmm_eval.go | 43 ++++++- src/pkg/dashboard/api_acmm_eval_test.go | 154 ++++++++++++++++++++++++ 5 files changed, 219 insertions(+), 4 deletions(-) create mode 100644 changelog.d/fixed-acmm-install-e2e.md diff --git a/changelog.d/fixed-acmm-install-e2e.md b/changelog.d/fixed-acmm-install-e2e.md new file mode 100644 index 0000000000..6ffe3d45a3 --- /dev/null +++ b/changelog.d/fixed-acmm-install-e2e.md @@ -0,0 +1 @@ +- Recognize install, boot, and explicitly named E2E GitHub Actions workflows in the ACMM E2E prerequisite, retaining web/configuration and directory alternatives without treating unrelated CI workflows as E2E coverage. diff --git a/src/docs/acmm-policy-matrix.md b/src/docs/acmm-policy-matrix.md index ead738c3a2..d4ab1c384e 100644 --- a/src/docs/acmm-policy-matrix.md +++ b/src/docs/acmm-policy-matrix.md @@ -16,6 +16,27 @@ issues. The **KB** is the knowledge base of reusable facts; an **RFC** is a request for comments on a proposed design. For a first deployment's trust choices, start with [Securing your hive](securing-your-hive.md). +## Repository E2E detection + +The codebase evaluator's `acmm:prereq-e2e` prerequisite accepts the existing +Playwright/Cypress configuration and E2E directory conventions, as well as +GitHub Actions workflow files named `test*-install*.yml`, `test*-boot*.yml`, +or `*e2e*.yml` (also `.yaml`). These workflow alternatives cover projects +whose end-to-end boundary is installing and booting a system rather than +driving a web browser. + +Workflow patterns use Go `path.Match` semantics on the file basename, only +inside the literal `.github/workflows` directory. They do not recurse, match +directories named like workflow files, or accept an unrelated CI workflow +just because it exists. Detection remains a file-existence heuristic, not +proof that a workflow passes or that its contents implement an E2E test; +maintainers must keep these paths backed by real coverage rather than add +empty directories or dummy workflows to satisfy the criterion. + +An evaluator fix takes effect only after a release containing it is deployed. +After deployment, refresh the ACMM evaluation (subject to its refresh debounce) +before closing an existing false-negative gap issue. + ## Policy Modes The four policy tiers below describe the main autonomy ladder. The roster also diff --git a/src/pkg/dashboard/acmm_criteria.go b/src/pkg/dashboard/acmm_criteria.go index 3c15358907..72c9a7b8f4 100644 --- a/src/pkg/dashboard/acmm_criteria.go +++ b/src/pkg/dashboard/acmm_criteria.go @@ -8,7 +8,7 @@ type ACMMCriterion struct { Level int // 0, 2, 3, 4, 5, 6 Category string Name string - Patterns []string // file paths to check (pass if ANY exists) + Patterns []string // paths or file-basename globs (pass if ANY exists) } // acmmLevelNames maps numeric ACMM levels to human-readable names. Levels @@ -35,7 +35,7 @@ var universalCriteria = []ACMMCriterion{ {ID: "acmm:prereq-test-suite", Source: "acmm", Level: 0, Category: "prerequisite", Name: "Test suite", Patterns: []string{"vitest.config.ts", "vitest.config.js", "jest.config.js", "jest.config.ts", "go.mod", "pytest.ini", "pyproject.toml", "test/", "tests/", "__tests__/", "spec/"}}, {ID: "acmm:prereq-e2e", Source: "acmm", Level: 0, Category: "prerequisite", Name: "E2E tests", - Patterns: []string{"playwright.config.ts", "playwright.config.js", "cypress.config.ts", "e2e/", "web/e2e/", "web/playwright.config.ts", "web/playwright.config.js", "test/e2e/", "tests/e2e/"}}, + Patterns: []string{"playwright.config.ts", "playwright.config.js", "cypress.config.ts", "e2e/", "web/e2e/", "web/playwright.config.ts", "web/playwright.config.js", "test/e2e/", "tests/e2e/", ".github/workflows/test*-install*.yml", ".github/workflows/test*-install*.yaml", ".github/workflows/test*-boot*.yml", ".github/workflows/test*-boot*.yaml", ".github/workflows/*e2e*.yml", ".github/workflows/*e2e*.yaml"}}, {ID: "acmm:prereq-cicd", Source: "acmm", Level: 0, Category: "prerequisite", Name: "CI/CD pipeline", Patterns: []string{".github/workflows/", ".gitlab-ci.yml", "Jenkinsfile", ".circleci/"}}, {ID: "acmm:prereq-pr-template", Source: "acmm", Level: 0, Category: "prerequisite", Name: "PR template", diff --git a/src/pkg/dashboard/api_acmm_eval.go b/src/pkg/dashboard/api_acmm_eval.go index 0b8e94fbdb..17c633660f 100644 --- a/src/pkg/dashboard/api_acmm_eval.go +++ b/src/pkg/dashboard/api_acmm_eval.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net/http" + pathpkg "path" "sort" "strconv" "strings" @@ -739,8 +740,8 @@ func newestHiveActivity(repo collect.RepoActivity) time.Time { return newest } -// patternExists checks if a file or directory path exists, using the -// pre-fetched directory cache when possible. +// patternExists checks a literal file/directory path or a path.Match glob in +// a file's basename. Parent directories are literal, not recursive globs. func (s *Server) patternExists(ctx context.Context, owner, repo, path string, dirCache map[string]map[string]bool) bool { isDir := strings.HasSuffix(path, "/") cleanPath := strings.TrimSuffix(path, "/") @@ -752,6 +753,44 @@ func (s *Server) patternExists(ctx context.Context, owner, repo, path string, di base = cleanPath[idx+1:] } + if strings.ContainsAny(base, "*?[") && !isDir { + entries, ok := dirCache[parent] + if !ok { + ghClient := s.deps.GHClient.GoGitHub() + if ghClient == nil { + return false + } + _, contents, _, err := ghClient.Repositories.GetContents(github.WithRESTCaller(ctx, "hive:acmm_pattern_exists"), owner, repo, parent, nil) + if err != nil { + // Cache the miss so sibling glob patterns under the same + // parent do not each re-issue the failed listing. + if dirCache != nil { + dirCache[parent] = map[string]bool{} + } + return false + } + entries = make(map[string]bool, len(contents)) + for _, entry := range contents { + entries[entry.GetName()] = true + if entry.GetType() == "dir" { + entries[entry.GetName()+"/"] = true + } + } + if dirCache != nil { + dirCache[parent] = entries + } + } + for name, exists := range entries { + if !exists || strings.HasSuffix(name, "/") || entries[name+"/"] { + continue + } + if matched, _ := pathpkg.Match(base, name); matched { + return true + } + } + return false + } + if entries, ok := dirCache[parent]; ok { if isDir { return entries[base+"/"] || entries[base] diff --git a/src/pkg/dashboard/api_acmm_eval_test.go b/src/pkg/dashboard/api_acmm_eval_test.go index fcf081d94d..7a41ef68ba 100644 --- a/src/pkg/dashboard/api_acmm_eval_test.go +++ b/src/pkg/dashboard/api_acmm_eval_test.go @@ -3,6 +3,7 @@ package dashboard import ( "context" "encoding/json" + "fmt" "io" "log/slog" "net/http" @@ -321,6 +322,159 @@ func TestPatternExists_NilGHClientOnCacheMiss(t *testing.T) { } } +func TestE2ECriterion_WorkflowAndWebAlternatives(t *testing.T) { + s := NewServer(0, acmmEvalTestLogger()) + deps := testDeps(t) + deps.GHClient = nil + s.RegisterAPI(deps) + c := findCriterion(t, "acmm:prereq-e2e") + + for _, tc := range []struct { + path string + want bool + }{ + {".github/workflows/test-plain-install.yml", true}, + {".github/workflows/test-luks-install.yml", true}, + {".github/workflows/test-network-install.yaml", true}, + {".github/workflows/test-uefi-boot.yml", true}, + {".github/workflows/test-secure-boot.yaml", true}, + {".github/workflows/e2e.yml", true}, + {".github/workflows/nightly-e2e.yaml", true}, + {"playwright.config.ts", true}, + {"playwright.config.js", true}, + {"cypress.config.ts", true}, + {"e2e/", true}, + {"web/e2e/", true}, + {"web/playwright.config.ts", true}, + {"web/playwright.config.js", true}, + {"test/e2e/", true}, + {"tests/e2e/", true}, + {".github/workflows/ci.yml", false}, + {".github/workflows/install-dependencies.yml", false}, + {".github/workflows/test-unit.yml", false}, + {".github/workflows/test-install.yml.disabled", false}, + {".github/workflows/test-install.yml/", false}, + {"docs/test-install.yml", false}, + {".github/workflows/nested/test-install.yml", false}, + } { + t.Run(tc.path, func(t *testing.T) { + cache := map[string]map[string]bool{} + for _, p := range c.Patterns { + clean := strings.TrimSuffix(p, "/") + parent := "" + if idx := strings.LastIndex(clean, "/"); idx >= 0 { + parent = clean[:idx] + } + cache[parent] = map[string]bool{} + } + clean := strings.TrimSuffix(tc.path, "/") + parent, base := "", clean + if idx := strings.LastIndex(clean, "/"); idx >= 0 { + parent, base = clean[:idx], clean[idx+1:] + } + if cache[parent] == nil { + cache[parent] = map[string]bool{} + } + cache[parent][base] = true + if strings.HasSuffix(tc.path, "/") { + cache[parent][base+"/"] = true + } + if got := s.checkCriterion(t.Context(), "myorg", "repo1", c, cache); got != tc.want { + t.Fatalf("E2E detection for %q = %v, want %v", tc.path, got, tc.want) + } + }) + } +} + +func TestPatternExists_FileGlobCacheAndFallback(t *testing.T) { + for _, cached := range []bool{true, false} { + for _, tc := range []struct { + name string + pattern string + isDir bool + want bool + }{ + {"matching file", "test*-install*.yml", false, true}, + {"question and class", "test-?-install.[y]ml", false, true}, + {"unrelated file", "*e2e*.yml", false, false}, + {"invalid glob", "[", false, false}, + {"directory named like workflow", "test*-install*.yml", true, false}, + } { + t.Run(fmt.Sprintf("cached=%v/%s", cached, tc.name), func(t *testing.T) { + calls := 0 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + calls++ + if r.URL.Path != "/repos/myorg/repo1/contents/.github/workflows" { + t.Errorf("glob queried %q, want parent directory listing", r.URL.Path) + http.NotFound(w, r) + return + } + entryType := "file" + if tc.isDir { + entryType = "dir" + } + w.Header().Set("Content-Type", "application/json") + _ = json.NewEncoder(w).Encode([]map[string]string{ + {"name": "test-a-install.yml", "type": entryType}, + }) + })) + t.Cleanup(ts.Close) + s := NewServer(0, acmmEvalTestLogger()) + deps := testDeps(t) + deps.GHClient = ghpkg.NewClientForTest(ts.URL, "myorg", []string{"repo1"}, acmmEvalTestLogger()) + s.RegisterAPI(deps) + cache := map[string]map[string]bool{} + if cached { + cache[".github/workflows"] = map[string]bool{"test-a-install.yml": true} + if tc.isDir { + cache[".github/workflows"]["test-a-install.yml/"] = true + } + } + for range 2 { + if got := s.patternExists(t.Context(), "myorg", "repo1", ".github/workflows/"+tc.pattern, cache); got != tc.want { + t.Fatalf("patternExists = %v, want %v", got, tc.want) + } + } + wantCalls := 1 + if cached { + wantCalls = 0 + } + if calls != wantCalls { + t.Fatalf("directory API calls = %d, want %d", calls, wantCalls) + } + }) + } + } +} + +func TestPatternExists_FileGlobMissingParentCachedOnce(t *testing.T) { + calls := 0 + ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + calls++ + http.NotFound(w, r) + })) + t.Cleanup(ts.Close) + s := NewServer(0, acmmEvalTestLogger()) + deps := testDeps(t) + deps.GHClient = ghpkg.NewClientForTest(ts.URL, "myorg", []string{"repo1"}, acmmEvalTestLogger()) + s.RegisterAPI(deps) + cache := map[string]map[string]bool{} + for _, pattern := range []string{"test*-install*.yml", "test*-boot*.yaml", "*e2e*.yml"} { + if s.patternExists(t.Context(), "myorg", "repo1", ".github/workflows/"+pattern, cache) { + t.Fatalf("patternExists(%q) = true for missing parent directory", pattern) + } + } + if calls != 1 { + t.Fatalf("directory API calls = %d, want 1 (missing parent should be cached)", calls) + } + if s.patternExists(t.Context(), "myorg", "repo1", ".github/workflows/ci.yml", cache) { + t.Fatal("literal lookup under cached missing parent should be false") + } + if calls != 1 { + t.Fatalf("directory API calls after literal lookup = %d, want 1", calls) + } +} + func TestCheckCriterion_AnyPatternMatches(t *testing.T) { s := NewServer(0, acmmEvalTestLogger()) From da691ee481db9fd8c92739c0b6b62255170026c1 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 13:55:44 -0500 Subject: [PATCH 06/24] =?UTF-8?q?=F0=9F=90=9B=20Activity=20Monitor:=20say?= =?UTF-8?q?=20'hive=20bot=20lacks=20permission',=20not=20'unauthorized'=20?= =?UTF-8?q?(#16641)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The muted pill for a PR whose next step the hive's GitHub App cannot take read 'unauthorized', which blames the person. It now reads 'hive bot lacks permission'; the tooltip, row hover line, Needs-attention chip title, needs-human tip, human-merge gate word and decision popover say the same. Label hive:unauthorized, comment marker and API fields are unchanged. Fixes #16639 Signed-off-by: Andrew Anderson --- .../changed-hive-permission-pill-wording.md | 1 + src/pkg/dashboard/stage_tracker_caption.go | 18 +++++++++++------- .../dashboard/stage_tracker_decision_lanes.go | 4 ++-- src/pkg/dashboard/stage_tracker_decision_pr.go | 2 +- .../dashboard/stage_tracker_pills_gate_test.go | 4 ++-- .../stage_tracker_unauthorized_test.go | 18 +++++++++--------- src/pkg/dashboard/static-src/html/tracker.html | 2 +- src/pkg/dashboard/static-src/js/agent-now.js | 2 +- .../static-src/js/tracker-row-strip.js | 4 ++-- src/pkg/dashboard/static-src/js/tracker-row.js | 4 +++- .../static-src/js/tracker-words-stage.js | 2 +- src/pkg/dashboard/static/index.html | 14 ++++++++------ 12 files changed, 42 insertions(+), 33 deletions(-) create mode 100644 changelog.d/changed-hive-permission-pill-wording.md diff --git a/changelog.d/changed-hive-permission-pill-wording.md b/changelog.d/changed-hive-permission-pill-wording.md new file mode 100644 index 0000000000..e21b15a3bc --- /dev/null +++ b/changelog.d/changed-hive-permission-pill-wording.md @@ -0,0 +1 @@ +- Activity Monitor: the muted pill a PR wears while the hive's GitHub App is missing a permission now reads "hive bot lacks permission" instead of "unauthorized", and its tooltip, the row hover line, the Needs-attention chip title, the needs-human tip, the human-merge gate word and the decision popover say the same — nobody did anything illegitimate, the App installation lacks one permission (hivecommons/hive#16639). The `hive:unauthorized` label, comment marker and API fields are unchanged. diff --git a/src/pkg/dashboard/stage_tracker_caption.go b/src/pkg/dashboard/stage_tracker_caption.go index 3168e11912..a4f5321107 100644 --- a/src/pkg/dashboard/stage_tracker_caption.go +++ b/src/pkg/dashboard/stage_tracker_caption.go @@ -457,12 +457,16 @@ func unauthorizedStepWords(step string) string { return strings.ReplaceAll(strings.TrimSpace(step), "-", " ") } -// Tooltip for the unauthorized pill, per step; the generic form serves a -// label whose stage reason does not (or no longer) names the step. +// Tooltip for the hive-bot-lacks-permission pill, per step; the generic +// form serves a label whose stage reason does not (or no longer) names the +// step. Operator wording says "hive bot lacks permission", never +// "unauthorized" (hivecommons/hive#16639): nobody did anything illegitimate, +// the App installation is missing one permission. The label name +// hive:unauthorized is a contract and stays. const ( - stageTrackerUnauthorizedApproveRuns = "The hive's GitHub App lacks `actions: write`, so it cannot approve the workflow runs GitHub is holding for this head. A maintainer must click Approve and run on the PR's checks banner (or the Actions tab); see the hive:unauthorized comment for the run ids. Hive resumes, and clears the label, once the required checks report." - stageTrackerUnauthorizedGeneric = "The hive's GitHub App lacks a permission for the next step, so only a person can take it; the hive:unauthorized comment on the PR names the permission and the step. Hive resumes, and clears the label, once the step is done." - stageTrackerUnauthorizedMergeWF = "The hive's GitHub App lacks `workflows: write`, so it cannot merge this owner-approved PR that edits .github/workflows files. A maintainer must click Merge on GitHub (the approval already stands), or grant the App Workflows: Read and write so the hive can merge such PRs itself." + stageTrackerUnauthorizedApproveRuns = "The hive bot's GitHub App is missing the 'actions: write' permission needed to approve the workflow runs GitHub is holding for this head, so a person has to take that step: click Approve and run on the PR's checks banner (or the Actions tab); the `hive:unauthorized` comment on the PR lists the run ids. Hive resumes and clears the label once the required checks report." + stageTrackerUnauthorizedGeneric = "The hive bot's GitHub App is missing a permission needed for the next step, so a person has to take that step. The `hive:unauthorized` comment on the PR names the permission and the action; hive resumes and clears the label once it's done." + stageTrackerUnauthorizedMergeWF = "The hive bot's GitHub App is missing the 'workflows: write' permission needed to merge this owner-approved PR that edits .github/workflows files, so a person has to take that step: click Merge on GitHub (the approval already stands), or grant the App Workflows: Read and write so the hive can merge such PRs itself." ) // stageTrackerUnauthorized derives the gate word and the tooltip for an @@ -480,7 +484,7 @@ func stageTrackerUnauthorized(reason string) (step, tip string) { if rest == stageengineprstage.UnauthorizedStepMergeWorkflowPath { return step, stageTrackerUnauthorizedMergeWF } - return step, "The hive's GitHub App lacks the permission to " + step + ", so only a person can take that step; the hive:unauthorized comment on the PR names the permission and the action. Hive resumes, and clears the label, once the step is done." + return step, "The hive bot's GitHub App is missing the permission needed to " + step + ", so a person has to take that step. The `hive:unauthorized` comment on the PR names the permission and the action; hive resumes and clears the label once it's done." } // stageTrackerManualMergeReason reports whether a bare stage reason is a @@ -506,7 +510,7 @@ var stageTrackerHumanMergeReasonWords = map[string][2]string{ stageengineprstage.HumanMergeReasonMergeMethod: {"merge method", "The repo does not allow the merge method this PR needs"}, stageengineprstage.HumanMergeReasonAutoMergeOff: {"auto-merge off", "Auto-merge is off for this repo, so a person merges"}, stageengineprstage.HumanMergeReasonUntrustedAuthor: {"untrusted author", "Hive won't merge it alone — the author isn't a trusted author yet"}, - stageengineprstage.HumanMergeReasonUnauthorized: {"unauthorized", "GitHub does not let hive merge here; a person merges"}, + stageengineprstage.HumanMergeReasonUnauthorized: {"hive bot lacks permission", "The hive bot's GitHub App is missing the permission to merge here; a person merges"}, stageengineprstage.HumanMergeReasonReviewerDeferred: {"reviewer deferred", "A reviewer asked for a person to merge this one"}, stageengineprstage.HumanMergeReasonBreakingChange: {"human merge", "Breaking change — owner merges; hive never merges a ⚠️-titled or needs-owner-merge PR"}, } diff --git a/src/pkg/dashboard/stage_tracker_decision_lanes.go b/src/pkg/dashboard/stage_tracker_decision_lanes.go index 68850309a7..e994922330 100644 --- a/src/pkg/dashboard/stage_tracker_decision_lanes.go +++ b/src/pkg/dashboard/stage_tracker_decision_lanes.go @@ -60,9 +60,9 @@ func decisionForUnauthorized(it StageTrackerItem, held bool) *StageTrackerDecisi step := strings.TrimSpace(it.UnauthorizedStep) if step == "" { _, tip := stageTrackerUnauthorized(it.Reason) - d.Question = "The hive's GitHub App lacks a permission for the next step. " + tip + d.Question = "The hive bot lacks a permission for the next step. " + tip } else { - d.Question = "The hive's GitHub App may not " + unauthorizedStepWords(step) + " here. Do that step on GitHub, then re-evaluate so the hive picks it up." + d.Question = "The hive bot's GitHub App is missing the permission to " + unauthorizedStepWords(step) + " here. Do that step on GitHub, then re-evaluate so the hive picks it up." } d.Blocker = strings.TrimSpace(it.Unauthorized) if d.Blocker == "" { diff --git a/src/pkg/dashboard/stage_tracker_decision_pr.go b/src/pkg/dashboard/stage_tracker_decision_pr.go index 0ee6c76d32..5fc5fbc303 100644 --- a/src/pkg/dashboard/stage_tracker_decision_pr.go +++ b/src/pkg/dashboard/stage_tracker_decision_pr.go @@ -50,7 +50,7 @@ func decisionForPR(it StageTrackerItem, verdict *review.Aggregate, sentinelLabel switch { case it.UnauthorizedStep != "": d.AskedBy = decisionAskedByApp - d.Question = "The hive's GitHub App may not " + unauthorizedStepWords(it.UnauthorizedStep) + " here. A maintainer has to do that step on GitHub." + d.Question = "The hive bot's GitHub App is missing the permission to " + unauthorizedStepWords(it.UnauthorizedStep) + " here. A maintainer has to do that step on GitHub." d.Blocker = strings.TrimSpace(it.Unauthorized) delegateOK, delegateWhy = false, decisionWhyNoPermission approveOK, approveWhy = false, decisionWhyApproveNoGrant diff --git a/src/pkg/dashboard/stage_tracker_pills_gate_test.go b/src/pkg/dashboard/stage_tracker_pills_gate_test.go index b3f805643d..9024aaa40a 100644 --- a/src/pkg/dashboard/stage_tracker_pills_gate_test.go +++ b/src/pkg/dashboard/stage_tracker_pills_gate_test.go @@ -133,7 +133,7 @@ func TestStageTrackerDeferredPillsPayload(t *testing.T) { if !strings.Contains(string(raw), `"modifiers":[],"deferred_modifiers":["sentinel","needs-human"]`) || !strings.Contains(string(raw), `"sentinel_alert":true`) { t.Fatalf("payload: %s", raw) } - if held := trackerItem(t, resp, "pr", 141); held.Stage != 72 || !hasMod(held, modUnauthorized) || len(held.DeferredModifiers) != 0 || held.UnauthorizedStep != "approve workflow runs" || !strings.Contains(held.Unauthorized, "`actions: write`") { + if held := trackerItem(t, resp, "pr", 141); held.Stage != 72 || !hasMod(held, modUnauthorized) || len(held.DeferredModifiers) != 0 || held.UnauthorizedStep != "approve workflow runs" || !strings.Contains(held.Unauthorized, "'actions: write'") { t.Fatalf("PR 141 = stage %d mods %v deferred %v step %q", held.Stage, held.Modifiers, held.DeferredModifiers, held.UnauthorizedStep) } if refused := trackerItem(t, resp, "pr", 142); refused.Stage != 50 || hasMod(refused, modUnauthorized) || !slices.Equal(refused.DeferredModifiers, []string{modUnauthorized}) || refused.UnauthorizedStep != "merge" { @@ -225,7 +225,7 @@ const gate80 = { kind: 'pr', stage: 80, modifiers: [], sentinel_alert: true, hea assert.ok(stageTrackerChipsHtml(gate80).includes('ham-badge-sentinel'), 'sentinel chip at 080'); // Actionable-now pills show wherever the row stands. assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 50, modifiers: ['hold'], deferred_modifiers: ['needs-human'] }).includes('>hold<')); -assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 72, modifiers: ['unauthorized'], unauthorized: 'needs actions: write' }).includes('>unauthorized<')); +assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 72, modifiers: ['unauthorized'], unauthorized: 'needs actions: write' }).includes('>hive bot lacks permission<')); assert.ok(stageTrackerNeedsAttention({ kind: 'pr', stage: 50, modifiers: ['hold'], deferred_modifiers: ['needs-human'] })); // A payload without the field (older server) renders exactly as before. assert.ok(stageTrackerChipsHtml({ kind: 'pr', stage: 50, modifiers: ['needs-human'], sentinel_alert: true }).includes('ham-badge-sentinel')); diff --git a/src/pkg/dashboard/stage_tracker_unauthorized_test.go b/src/pkg/dashboard/stage_tracker_unauthorized_test.go index 2fd5d63a1f..4f57a14db2 100644 --- a/src/pkg/dashboard/stage_tracker_unauthorized_test.go +++ b/src/pkg/dashboard/stage_tracker_unauthorized_test.go @@ -31,11 +31,11 @@ func TestStageTrackerUnauthorizedFromReason(t *testing.T) { for _, tc := range []struct { name, reason, wantStep, wantTip string }{ - {name: "approve workflow runs", reason: approve, wantStep: "approve workflow runs", wantTip: "`actions: write`"}, + {name: "approve workflow runs", reason: approve, wantStep: "approve workflow runs", wantTip: "'actions: write'"}, {name: "human-approved suffix is stripped", reason: approve + ":human-approved@pat", wantStep: "approve workflow runs", wantTip: "Approve and run"}, - {name: "another step", reason: prstage.StageReasonUnauthorizedPrefix + "update-branch", wantStep: "update branch", wantTip: "permission to update branch"}, - {name: "label without a reason", reason: "contributor-lane:soaking(1h)", wantTip: "lacks a permission for the next step"}, - {name: "empty", reason: "", wantTip: "lacks a permission for the next step"}, + {name: "another step", reason: prstage.StageReasonUnauthorizedPrefix + "update-branch", wantStep: "update branch", wantTip: "permission needed to update branch"}, + {name: "label without a reason", reason: "contributor-lane:soaking(1h)", wantTip: "missing a permission needed for the next step"}, + {name: "empty", reason: "", wantTip: "missing a permission needed for the next step"}, } { t.Run(tc.name, func(t *testing.T) { step, tip := stageTrackerUnauthorized(tc.reason) @@ -63,7 +63,7 @@ func TestStageTrackerUnauthorizedPayload(t *testing.T) { s.statusMu.Unlock() resp := s.buildStageTracker(s.status, store, now) it := trackerItem(t, resp, "pr", 130) - if it.Stage != 85 || !hasMod(it, modUnauthorized) || it.UnauthorizedStep != "approve workflow runs" || !strings.Contains(it.Unauthorized, "`actions: write`") { + 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.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" { @@ -73,7 +73,7 @@ func TestStageTrackerUnauthorizedPayload(t *testing.T) { if err != nil { t.Fatal(err) } - if !strings.Contains(string(raw), `"unauthorized_step":"approve workflow runs"`) || !strings.Contains(string(raw), `"unauthorized":"The hive's GitHub App lacks`) { + if !strings.Contains(string(raw), `"unauthorized_step":"approve workflow runs"`) || !strings.Contains(string(raw), `"unauthorized":"The hive bot's GitHub App is missing`) { t.Fatalf("payload lacks the unauthorized fields: %s", raw) } if clean := trackerItem(t, resp, "pr", 101); clean.UnauthorizedStep != "" || clean.Unauthorized != "" || hasMod(clean, modUnauthorized) { @@ -118,15 +118,15 @@ func TestStageTrackerUnauthorizedJS(t *testing.T) { jsFunc(t, html, "stageTrackerChipsHtml"), jsFunc(t, html, "stageTrackerNeedsAttention"), }, "\n") + ` -const tip = "The hive's GitHub App lacks \u0060actions: write\u0060, so it cannot approve the workflow runs."; +const tip = "The hive bot's GitHub App is missing the 'actions: write' permission needed to approve the workflow runs."; const item = { kind: 'pr', stage: 85, modifiers: ['unauthorized'], unauthorized_step: 'approve workflow runs', unauthorized: tip }; const pill = stageTrackerChipsHtml(item); -assert.ok(pill.includes('ham-mod-unauthorized') && pill.includes('>unauthorized<'), pill); +assert.ok(pill.includes('ham-mod-unauthorized') && pill.includes('>hive bot lacks permission<'), pill); assert.ok(pill.includes('title="' + esc(tip) + '"'), pill); assert.ok(STAGE_TRACKER_HUMAN_MODS.includes('unauthorized') && STAGE_TRACKER_MOTION_HUMAN_MODS.includes('unauthorized')); assert.ok(stageTrackerNeedsAttention(item)); // unauthorized outranks the needs-* chips but yields to hold, a human instruction. -assert.ok(stageTrackerChipsHtml({ stage: 85, modifiers: ['needs-decision', 'unauthorized'] }).includes('>unauthorized +1<')); +assert.ok(stageTrackerChipsHtml({ stage: 85, modifiers: ['needs-decision', 'unauthorized'] }).includes('>hive bot lacks permission +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), 'Waiting for a maintainer · approve workflow runs on GitHub'); diff --git a/src/pkg/dashboard/static-src/html/tracker.html b/src/pkg/dashboard/static-src/html/tracker.html index 1c9c43ddb4..2e8a126309 100644 --- a/src/pkg/dashboard/static-src/html/tracker.html +++ b/src/pkg/dashboard/static-src/html/tracker.html @@ -24,7 +24,7 @@

    Hive activity moni - + diff --git a/src/pkg/dashboard/static-src/js/agent-now.js b/src/pkg/dashboard/static-src/js/agent-now.js index c09df5ea3b..700418a59d 100644 --- a/src/pkg/dashboard/static-src/js/agent-now.js +++ b/src/pkg/dashboard/static-src/js/agent-now.js @@ -486,7 +486,7 @@ // "workflow-files" / "untrusted-author" / "branch-protection", falling // back to "policy"); the tooltip carries the payload's one-sentence // human_merge_reason_text (hivecommons/hive#14658). - const STAGE_TRACKER_HUMAN_MERGE_REASON_WORD = { 'workflow-files': 'workflow files', 'tests-removed': 'tests removed', 'manual-merge-policy': 'manual-merge policy', 'branch-protection': 'branch protection', 'merge-method': 'merge method', 'auto-merge-off': 'auto-merge off', 'untrusted-author': 'untrusted author', 'unauthorized': 'unauthorized', 'reviewer-deferred': 'reviewer deferred', 'breaking-change': 'human merge', 'policy': 'policy' }; + const STAGE_TRACKER_HUMAN_MERGE_REASON_WORD = { 'workflow-files': 'workflow files', 'tests-removed': 'tests removed', 'manual-merge-policy': 'manual-merge policy', 'branch-protection': 'branch protection', 'merge-method': 'merge method', 'auto-merge-off': 'auto-merge off', 'untrusted-author': 'untrusted author', 'unauthorized': 'hive bot lacks permission', 'reviewer-deferred': 'reviewer deferred', 'breaking-change': 'human merge', 'policy': 'policy' }; // 090 under the breaking-change rule (human_merge_reason // "breaking-change": a ⚠️ title or needs-owner-merge label, // hivecommons/hive#15442): no approval lets the hive merge it, so the 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 2c057d4b09..ab5bc22605 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -675,7 +675,7 @@ if (item.sentinel_alert && deferred.indexOf(STAGE_TRACKER_SENTINEL_CHIP) < 0) lines.push(stageTrackerSentinelTip(item)); const regressed = stageTrackerRegressionText(item, nowMs); if (regressed) lines.push(regressed.charAt(0).toUpperCase() + regressed.slice(1)); - if (mods.indexOf('unauthorized') >= 0 && item.unauthorized) lines.push('Unauthorized: ' + item.unauthorized); + if (mods.indexOf('unauthorized') >= 0 && item.unauthorized) lines.push('Hive bot lacks permission: ' + item.unauthorized); if (mods.indexOf('hold') >= 0 && typeof stageTrackerHoldPill === 'function' && stageTrackerHoldPill(item)) lines.push(stageTrackerHoldPill(item)); if (sinceMs) lines.push('Since ' + agentNowClockTime(sinceMs, nowMs) + ' · ' + agentNowAgo(nowMs - sinceMs)); if (trail) lines.push('Trail: ' + trail); @@ -778,7 +778,7 @@ // The regressed pill (lead or folded into "+1") explains itself on // hover; failing that, a draft pill (lead or folded) does. const regressed = stageTrackerRegressionText(item, Date.now()); - // An unauthorized pill names the missing App permission and the human step; + // A hive-bot-lacks-permission pill names the missing App permission and the human step; // the regressed pill explains itself; a blocked pill names what it waits on; // failing all three, a draft pill does. const anyBlockedPR = mods.indexOf('blocked') >= 0 ? stageTrackerBlockedOnPR(item) : null; diff --git a/src/pkg/dashboard/static-src/js/tracker-row.js b/src/pkg/dashboard/static-src/js/tracker-row.js index 609e076a22..f1ddcac67e 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row.js +++ b/src/pkg/dashboard/static-src/js/tracker-row.js @@ -109,7 +109,9 @@ } const STAGE_TRACKER_MOD_PRIORITY = ['stalled', 'regressed', 'hold', 'unauthorized', 'needs-human', 'needs-decision', 'needs-triage', 'possible-dupe', 'needs-rebase', 'blocked', 'draft']; - const STAGE_TRACKER_MOD_TEXT = { 'needs-decision': 'needs human decision', 'needs-triage': 'triage needed', 'possible-dupe': 'possible dupe' }; + // hive:unauthorized reads "hive bot lacks permission", never "unauthorized": the App + // installation is missing a permission, nobody did anything illegitimate (hivecommons/hive#16639). + const STAGE_TRACKER_MOD_TEXT = { 'needs-decision': 'needs human decision', 'needs-triage': 'triage needed', 'possible-dupe': 'possible dupe', unauthorized: 'hive bot lacks permission' }; // The draft pill and the Draft chevron explain themselves on hover: no // maintainer action is pending, the lanes resume when the author is ready. const STAGE_TRACKER_DRAFT_TIP = 'Draft PR — hive review and merge lanes skip drafts until the author marks it ready for review.'; diff --git a/src/pkg/dashboard/static-src/js/tracker-words-stage.js b/src/pkg/dashboard/static-src/js/tracker-words-stage.js index 814078faca..8315b8eeba 100644 --- a/src/pkg/dashboard/static-src/js/tracker-words-stage.js +++ b/src/pkg/dashboard/static-src/js/tracker-words-stage.js @@ -62,7 +62,7 @@ const STAGE_TRACKER_NEEDS_HUMAN_STAGES = [15, 45, 85, 90]; const STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES = [71, 72]; const STAGE_TRACKER_NEEDS_HUMAN_MODS = ['needs-human', 'needs-decision', 'unauthorized']; - const STAGE_TRACKER_NEEDS_HUMAN_TIP = 'Only a person can move these: triage needed, needs decision, human author must act, human merge, or a needs-human / unauthorized pill'; + const STAGE_TRACKER_NEEDS_HUMAN_TIP = 'Only a person can move these: triage needed, needs decision, human author must act, human merge, or a needs-human / hive-bot-lacks-permission pill'; const STAGE_TRACKER_ON_HOLD_TIP = 'Paused on purpose with a hold label — waiting on nobody; remove the hold to resume'; // Label families a chip row is built from, in display order; other // labels follow when at least two items carry them. diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index c6d55193e0..8a98283cbc 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -8395,7 +8395,7 @@

    Hive activity moni - + @@ -15383,7 +15383,7 @@

    Where to get help

    // "workflow-files" / "untrusted-author" / "branch-protection", falling // back to "policy"); the tooltip carries the payload's one-sentence // human_merge_reason_text (hivecommons/hive#14658). - const STAGE_TRACKER_HUMAN_MERGE_REASON_WORD = { 'workflow-files': 'workflow files', 'tests-removed': 'tests removed', 'manual-merge-policy': 'manual-merge policy', 'branch-protection': 'branch protection', 'merge-method': 'merge method', 'auto-merge-off': 'auto-merge off', 'untrusted-author': 'untrusted author', 'unauthorized': 'unauthorized', 'reviewer-deferred': 'reviewer deferred', 'breaking-change': 'human merge', 'policy': 'policy' }; + const STAGE_TRACKER_HUMAN_MERGE_REASON_WORD = { 'workflow-files': 'workflow files', 'tests-removed': 'tests removed', 'manual-merge-policy': 'manual-merge policy', 'branch-protection': 'branch protection', 'merge-method': 'merge method', 'auto-merge-off': 'auto-merge off', 'untrusted-author': 'untrusted author', 'unauthorized': 'hive bot lacks permission', 'reviewer-deferred': 'reviewer deferred', 'breaking-change': 'human merge', 'policy': 'policy' }; // 090 under the breaking-change rule (human_merge_reason // "breaking-change": a ⚠️ title or needs-owner-merge label, // hivecommons/hive#15442): no approval lets the hive merge it, so the @@ -16262,7 +16262,7 @@

    Where to get help

    const STAGE_TRACKER_NEEDS_HUMAN_STAGES = [15, 45, 85, 90]; const STAGE_TRACKER_NEEDS_HUMAN_AUTHOR_STAGES = [71, 72]; const STAGE_TRACKER_NEEDS_HUMAN_MODS = ['needs-human', 'needs-decision', 'unauthorized']; - const STAGE_TRACKER_NEEDS_HUMAN_TIP = 'Only a person can move these: triage needed, needs decision, human author must act, human merge, or a needs-human / unauthorized pill'; + const STAGE_TRACKER_NEEDS_HUMAN_TIP = 'Only a person can move these: triage needed, needs decision, human author must act, human merge, or a needs-human / hive-bot-lacks-permission pill'; const STAGE_TRACKER_ON_HOLD_TIP = 'Paused on purpose with a hold label — waiting on nobody; remove the hold to resume'; // Label families a chip row is built from, in display order; other // labels follow when at least two items carry them. @@ -17653,7 +17653,9 @@

    Where to get help

    } const STAGE_TRACKER_MOD_PRIORITY = ['stalled', 'regressed', 'hold', 'unauthorized', 'needs-human', 'needs-decision', 'needs-triage', 'possible-dupe', 'needs-rebase', 'blocked', 'draft']; - const STAGE_TRACKER_MOD_TEXT = { 'needs-decision': 'needs human decision', 'needs-triage': 'triage needed', 'possible-dupe': 'possible dupe' }; + // hive:unauthorized reads "hive bot lacks permission", never "unauthorized": the App + // installation is missing a permission, nobody did anything illegitimate (hivecommons/hive#16639). + const STAGE_TRACKER_MOD_TEXT = { 'needs-decision': 'needs human decision', 'needs-triage': 'triage needed', 'possible-dupe': 'possible dupe', unauthorized: 'hive bot lacks permission' }; // The draft pill and the Draft chevron explain themselves on hover: no // maintainer action is pending, the lanes resume when the author is ready. const STAGE_TRACKER_DRAFT_TIP = 'Draft PR — hive review and merge lanes skip drafts until the author marks it ready for review.'; @@ -18582,7 +18584,7 @@

    Where to get help

    if (item.sentinel_alert && deferred.indexOf(STAGE_TRACKER_SENTINEL_CHIP) < 0) lines.push(stageTrackerSentinelTip(item)); const regressed = stageTrackerRegressionText(item, nowMs); if (regressed) lines.push(regressed.charAt(0).toUpperCase() + regressed.slice(1)); - if (mods.indexOf('unauthorized') >= 0 && item.unauthorized) lines.push('Unauthorized: ' + item.unauthorized); + if (mods.indexOf('unauthorized') >= 0 && item.unauthorized) lines.push('Hive bot lacks permission: ' + item.unauthorized); if (mods.indexOf('hold') >= 0 && typeof stageTrackerHoldPill === 'function' && stageTrackerHoldPill(item)) lines.push(stageTrackerHoldPill(item)); if (sinceMs) lines.push('Since ' + agentNowClockTime(sinceMs, nowMs) + ' · ' + agentNowAgo(nowMs - sinceMs)); if (trail) lines.push('Trail: ' + trail); @@ -18685,7 +18687,7 @@

    Where to get help

    // The regressed pill (lead or folded into "+1") explains itself on // hover; failing that, a draft pill (lead or folded) does. const regressed = stageTrackerRegressionText(item, Date.now()); - // An unauthorized pill names the missing App permission and the human step; + // A hive-bot-lacks-permission pill names the missing App permission and the human step; // the regressed pill explains itself; a blocked pill names what it waits on; // failing all three, a draft pill does. const anyBlockedPR = mods.indexOf('blocked') >= 0 ? stageTrackerBlockedOnPR(item) : null; From 655fa3faabf380fa618c3221856840e012a50ea5 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 14:11:03 -0500 Subject: [PATCH 07/24] fix(automerge): never supersede a hive-authored PR for a missing sign-off (#16648) The squash-attribution rule in stageDCO counted an App-signed commit on a PR by hive's own ai_author as squash-unsafe, so signoff-rehome closed the approved, green PR and re-authored it as a new one. Hive-authored PRs are now self-squash, signoff-rehome amends them in place (or leaves them) and never rehomes an operator-approved head. The App's signed re-author commit always carries a Signed-off-by trailer and the push relay refuses a hive-identity commit without one. Fixes #16647 Signed-off-by: Andrew Anderson --- .../fixed-signoff-rehome-hive-authored.md | 1 + src/cmd/hive/merge_eligibility.go | 1 + .../automerge_adoption_escape_test.go | 114 ++++++++++++++++++ .../automerge/automerge_contributor_adopt.go | 69 +++++++++-- .../automerge_contributor_adopt_test.go | 38 ++++-- .../github/automerge/automerge_stage_dco.go | 41 ++++++- .../automerge/automerge_stage_labels.go | 8 +- .../automerge/shared_ci_attribution_test.go | 2 +- src/pkg/github/pr_request_signed.go | 17 +++ src/pkg/github/pr_request_signed_test.go | 21 ++++ src/pkg/github/push_branch_request_watcher.go | 88 ++++++++++++++ .../push_branch_request_watcher_test.go | 69 ++++++++++- 12 files changed, 434 insertions(+), 35 deletions(-) create mode 100644 changelog.d/fixed-signoff-rehome-hive-authored.md diff --git a/changelog.d/fixed-signoff-rehome-hive-authored.md b/changelog.d/fixed-signoff-rehome-hive-authored.md new file mode 100644 index 0000000000..deff42eba9 --- /dev/null +++ b/changelog.d/fixed-signoff-rehome-hive-authored.md @@ -0,0 +1 @@ +- Hive no longer supersedes its own PRs for a missing sign-off: the automerge DCO stage treats commits on a PR by hive's `ai_author` or App login as self-squash (so an App-signed commit no longer counts as squash-unsafe), `signoff-rehome` keeps hive-authored and operator-approved heads in place instead of re-authoring them as a new PR, the App's signed re-author commit always carries a `Signed-off-by` trailer, and the push relay refuses a hive-identity commit that lacks one. diff --git a/src/cmd/hive/merge_eligibility.go b/src/cmd/hive/merge_eligibility.go index 992781e6d6..6883609482 100644 --- a/src/cmd/hive/merge_eligibility.go +++ b/src/cmd/hive/merge_eligibility.go @@ -130,6 +130,7 @@ func stageLabelPolicyFunc(cfg *config.Config) func() automerge.StageLabelPolicy AuthorKindLabels: cfg.Governor.Labels.Author.Names(), RelayKnown: contributorRelayKnown, OwnerAuthor: dashboardOwnerLogin(cfg), + HiveAuthor: hiveIdentity(cfg).Matches, SharedCIIncident: stageSharedCIIncident, BaseBranchRed: stageBaseBranchRed, ForkGuard: stageForkGuard, diff --git a/src/pkg/github/automerge/automerge_adoption_escape_test.go b/src/pkg/github/automerge/automerge_adoption_escape_test.go index 1a61b222c5..132e17a241 100644 --- a/src/pkg/github/automerge/automerge_adoption_escape_test.go +++ b/src/pkg/github/automerge/automerge_adoption_escape_test.go @@ -9,6 +9,7 @@ import ( "testing" "time" + gh "github.com/google/go-github/v72/github" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -639,3 +640,116 @@ func TestFormatSat(t *testing.T) { } } } + +// hivecommons/hive#16619: the hive's own clanker (project.ai_author) opened +// the PR from its fork; the hive's fixer pushed a commit signed as the App. +// The squash attributes that commit to the hive's own author, so there is +// nothing to re-home: the PR keeps its number, approval and CI, and the +// adoption stays in place. No superseder, no stall note. +func TestAdoptedInPlaceHiveAuthoredSquashUnsafeCommitStaysInPlace(t *testing.T) { + p := adoptPolicy() + p.AdoptInPlace = true + p.DCORequired = func(string) (bool, bool) { return true, true } + p.HiveAuthor = func(login string) bool { return strings.EqualFold(login, "thatguywob") } + h, done := newAdoptHarness(t, ContributorNudgeOutcome{Mode: "comment"}, p) + defer done() + h.api.commitDetails = map[int][]stageCommitFixture{7: { + {message: "fix: preserve verdicts\n\nSigned-off-by: thatguywob ", authorLogin: "thatguywob", authorName: "thatguywob", authorEmail: "thatguywob@users.noreply.github.com"}, + {message: "fix: escape tooltip lines\n\nSigned-off-by: hive[bot] <12345+hive[bot]@users.noreply.github.com>", authorLogin: testHiveAppBotLogin, authorName: "scanner", authorEmail: "12345+hive[bot]@users.noreply.github.com"}, + }} + own := func(head string, labels ...string) *gh.PullRequest { + pr := adoptPR(7, head, labels...) + pr.User = &gh.User{Login: gh.Ptr("thatguywob")} + pr.Head.Repo = &gh.Repository{FullName: gh.Ptr("thatguywob/widget")} + return pr + } + h.adopt.allowMaintainerEdits(7, true) + h.observe(own("5980996"), contributorLaneReasonNoVerdict) + key := stageKey("acme", "widget", 7) + h.e.stageStoreOrShared().MarkAdoptedInPlace(key, "5980996", AdoptReasonGrace, h.clock.at) + h.adopt.setCommitAuthor("5980996", testHiveAppBotLogin) + h.api.reset() + + for _, advance := range []time.Duration{time.Minute, adoptedDwell + time.Hour} { + h.clock.advance(advance) + h.observe(own("5980996", adoptedLabels...), contributorLaneReasonNoVerdict) + // Past the dwell the idle head may escalate to a person (085); + // that is a note on the same PR, never a copy of it. + if len(h.adopt.pulls) != 0 || len(adoptionComments(h.api)) != 0 || h.adopt.refs["refs/heads/hive/adopt-7"] != "" { + t.Fatalf("hive-authored PR superseded for sign-off: pulls=%v refs=%v comments=%v", h.adopt.pulls, h.adopt.refs, h.api.comments) + } + rec, _ := h.e.stageStoreOrShared().Get(key) + if !rec.AdoptedInPlace() || rec.AdoptedBy != 0 || rec.AdoptReason == AdoptReasonSignoffRehome || rec.DCOSquashUnsafeHive != 0 { + t.Fatalf("record after %v: %+v", advance, rec) + } + for _, c := range stalledComments(h.api) { + if strings.Contains(c, stagelabels.LaneReasonHiveSignoffAttribution) { + t.Fatalf("hive-authored PR parked on sign-off attribution: %s", c) + } + } + } +} + +// The same head on an external contributor's fork keeps the existing +// behaviour: the App-signed commit is squash-unsafe under mallory's name, +// so the adoption re-homes onto hive/adopt-7 at once +// (TestAdoptedInPlaceSquashUnsafeHiveCommitSupersedes covers the full +// path; this pins the decision with the hive-author hook present). +func TestAdoptedInPlaceExternalForkSquashUnsafeStillSupersedes(t *testing.T) { + policy := adoptPolicy() + policy.AdoptInPlace = true + policy.HiveAuthor = func(login string) bool { return strings.EqualFold(login, "thatguywob") } + now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC) + inPlace := stagelabels.Record{AdoptedHead: "aaa", AdoptMode: stagelabels.AdoptModeInPlace, AdoptedAt: now, AdoptedHeadAt: now} + external := stageObservation{HeadSHA: "aaa", Author: "mallory", HeadRepo: "mallory/widget", Reason: stagelabels.LaneReasonHiveSignoffAttribution, Detail: stageDetail{DCOSquashUnsafeHive: 1}} + if got := inPlaceRehomeReason(external, inPlace, policy, now.Add(time.Minute), false); got != AdoptReasonSignoffRehome { + t.Fatalf("external fork: inPlaceRehomeReason=%q, want %q", got, AdoptReasonSignoffRehome) + } + if got := adoptionStalledReason(external, inPlace, policy, now.Add(time.Minute)); got != "adoption-stalled:hive-signoff-attribution" { + t.Fatalf("external fork stall reason=%q", got) + } + own := external + own.Author, own.HeadRepo = "thatguywob", "thatguywob/widget" + if got := inPlaceRehomeReason(own, inPlace, policy, now.Add(time.Minute), false); got != "" { + t.Fatalf("hive-authored: inPlaceRehomeReason=%q, want none", got) + } + if got := adoptionStalledReason(own, inPlace, policy, now.Add(time.Minute)); got != "" { + t.Fatalf("hive-authored stall reason=%q, want none", got) + } +} + +// An operator's approval on the adopted head is never thrown away for a +// copy: neither the sign-off, the rebase nor the stalled-finding re-home +// fires while the approval stands on that head. A new head starts over. +func TestAdoptedInPlaceApprovedHeadIsNotSuperseded(t *testing.T) { + policy := adoptPolicy() + policy.AdoptInPlace = true + now := time.Date(2026, 10, 16, 12, 0, 0, 0, time.UTC) + inPlace := stagelabels.Record{AdoptedHead: "aaa", AdoptMode: stagelabels.AdoptModeInPlace, AdoptedAt: now, AdoptedHeadAt: now} + late := now.Add(adoptedDwell + time.Hour) + approved := stageDetail{HumanApprover: "clubanderson", HumanApprovalHead: "aaa"} + cases := []struct { + name string + obs stageObservation + }{ + {"squash-unsafe sign-off", stageObservation{HeadSHA: "aaa", Author: "mallory", Reason: stagelabels.LaneReasonHiveSignoffAttribution, Detail: stageDetail{DCOSquashUnsafeHive: 1}}}, + {"needs-rebase past dwell", stageObservation{HeadSHA: "aaa", Author: "mallory", Labels: []string{"needs-rebase"}, Reason: "conflicting"}}, + {"finding past dwell", stageObservation{HeadSHA: "aaa", Author: "mallory", LaneReason: contributorLaneReasonChangesRequested, Detail: stageDetail{VerdictKnown: true, Verdict: ContributorLaneVerdict{Configured: true, Verdict: "changes_requested"}}}}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + if got := inPlaceRehomeReason(tc.obs, inPlace, policy, late, true); got == "" { + t.Fatalf("precondition: unapproved head must re-home") + } + obs := tc.obs + obs.Detail.HumanApprover, obs.Detail.HumanApprovalHead = approved.HumanApprover, approved.HumanApprovalHead + if got := inPlaceRehomeReason(obs, inPlace, policy, late, true); got != "" { + t.Fatalf("approved head re-homed: %q", got) + } + obs.Detail.HumanApprovalHead = "older" + if got := inPlaceRehomeReason(obs, inPlace, policy, late, true); got == "" { + t.Fatalf("an approval on an older head must not pin the new one") + } + }) + } +} diff --git a/src/pkg/github/automerge/automerge_contributor_adopt.go b/src/pkg/github/automerge/automerge_contributor_adopt.go index f9d81604d6..4e7c9bd876 100644 --- a/src/pkg/github/automerge/automerge_contributor_adopt.go +++ b/src/pkg/github/automerge/automerge_contributor_adopt.go @@ -288,8 +288,8 @@ func adoptionCloses(body string) []string { return out } -func adoptionNeedsDCORehome(obs stageObservation, canPushInPlace bool) bool { - return adoptionDCORepairMode(obs, canPushInPlace) == stagelabels.AdoptModeSupersede +func adoptionNeedsDCORehome(obs stageObservation, canPushInPlace, hiveAuthored bool) bool { + return adoptionDCORepairMode(obs, canPushInPlace, hiveAuthored) == stagelabels.AdoptModeSupersede } // adoptionDCORepairMode decides how a DCO-red head gets its sign-off: @@ -298,16 +298,34 @@ func adoptionNeedsDCORehome(obs stageObservation, canPushInPlace bool) bool { // base repository — a fork branch is pushable by an agent's git but not by // the App's REST token, so a fork head re-homes (AdoptModeSupersede) even // when every unsigned commit is the hive's (hivecommons/hive#14666). -func adoptionDCORepairMode(obs stageObservation, canPushInPlace bool) string { +// +// A hive-authored PR (hiveAuthored: the App bot or project.ai_author opened +// it) is never re-homed: every commit on it is the hive's to sign, so a +// pushable base-repo head is amended in place and any other head keeps its +// PR number, approvals and CI history and waits for a person (""), +// rather than restarting as a copy (hivecommons/hive#16619). +func adoptionDCORepairMode(obs stageObservation, canPushInPlace, hiveAuthored bool) string { if obs.Detail.DCO != stagelabels.DCONo || obs.Detail.DCOUnsigned <= 0 { return "" } - if canPushInPlace && headInBaseRepo(obs) && obs.Detail.DCOUnsignedHive == obs.Detail.DCOUnsigned && obs.Detail.DCOUnsignedOther == 0 { + if canPushInPlace && headInBaseRepo(obs) && (hiveAuthored || (obs.Detail.DCOUnsignedHive == obs.Detail.DCOUnsigned && obs.Detail.DCOUnsignedOther == 0)) { return stagelabels.AdoptModeInPlace } + if hiveAuthored { + return "" + } return stagelabels.AdoptModeSupersede } +// adoptionHeadApproved reports whether a trusted human's APPROVED review +// stands on the observed head. Such a head is never re-homed onto a copy: +// the copy would restart CI and drop the approval (hivecommons/hive#16619). +// The one exception is a fork branch the hive cannot push to +// (AdoptReasonPushRehome), which the caller decides. +func adoptionHeadApproved(obs stageObservation) bool { + return obs.HeadSHA != "" && strings.TrimSpace(obs.Detail.HumanApprover) != "" && strings.TrimSpace(obs.Detail.HumanApprovalHead) == obs.HeadSHA +} + // headInBaseRepo reports whether the PR head lives in the base repository // (not a fork), where the App's git-data API can rewrite it. func headInBaseRepo(obs stageObservation) bool { @@ -317,8 +335,8 @@ func headInBaseRepo(obs stageObservation) bool { // adoptedHeadNeedsDCORepair decides, for an in-place-adopted PR, whether the // unsigned commits are the hive's own on a base-repo branch it rewrites in // place with its sign-off. -func adoptedHeadNeedsDCORepair(obs stageObservation, rec stagelabels.Record, canPushInPlace bool) bool { - return adoptedHeadDCORed(obs, rec) && adoptionDCORepairMode(obs, canPushInPlace) == stagelabels.AdoptModeInPlace +func adoptedHeadNeedsDCORepair(obs stageObservation, rec stagelabels.Record, canPushInPlace, hiveAuthored bool) bool { + return adoptedHeadDCORed(obs, rec) && adoptionDCORepairMode(obs, canPushInPlace, hiveAuthored) == stagelabels.AdoptModeInPlace } // adoptedHeadDCORed reports whether an in-place-adopted PR's head carries @@ -330,8 +348,8 @@ func adoptedHeadDCORed(obs stageObservation, rec stagelabels.Record) bool { // adoptedHeadNeedsDCORehome decides, for an in-place-adopted PR, whether the // unsigned commits can be rewritten on the contributor branch (all App-linked // and the branch still pushable) or the work must be re-homed. -func adoptedHeadNeedsDCORehome(obs stageObservation, rec stagelabels.Record, canPushInPlace bool) bool { - return adoptedHeadDCORed(obs, rec) && adoptionDCORepairMode(obs, canPushInPlace) == stagelabels.AdoptModeSupersede +func adoptedHeadNeedsDCORehome(obs stageObservation, rec stagelabels.Record, canPushInPlace, hiveAuthored bool) bool { + return adoptedHeadDCORed(obs, rec) && adoptionDCORepairMode(obs, canPushInPlace, hiveAuthored) == stagelabels.AdoptModeSupersede } func adoptionRehomeCommitMessage(obs stageObservation) string { @@ -696,7 +714,7 @@ func (c *Engine) adoptContributorPR(ctx context.Context, store *stagelabels.Stor if policy.AdoptInPlace && !requested && !forced { canPushInPlace = c.canPushToPRBranch(ctx, obs) } - dcoRehome := adoptionNeedsDCORehome(obs, canPushInPlace) + dcoRehome := adoptionNeedsDCORehome(obs, canPushInPlace, hiveAuthoredPR(obs, policy, appLogin)) // Record the attempt first: whatever happens below, this head is tried once. store.MarkAdopted(key, obs.HeadSHA, 0, now) store.NoteAdoptDiffFence(key, fence) @@ -1344,10 +1362,17 @@ func (c *Engine) settleAdoption(ctx context.Context, store *stagelabels.Store, k } if adoptedHeadDCORed(obs, rec) { canPushInPlace := c.canPushToPRBranch(ctx, obs) - if adoptedHeadNeedsDCORepair(obs, rec, canPushInPlace) { + hiveAuthored := hiveAuthoredPR(obs, policy, c.transport.AppBotLogin()) + if adoptedHeadNeedsDCORepair(obs, rec, canPushInPlace, hiveAuthored) { return c.repairAdoptedDCOInPlace(ctx, store, key, obs, rec) } - if adoptedHeadNeedsDCORehome(obs, rec, canPushInPlace) { + if hiveAuthored && !adoptionHeadApproved(obs) && obs.Detail.DCOUnsigned > 0 { + // The hive's own PR on a head it cannot rewrite over REST: + // it keeps its number, approvals and CI; the unsigned head + // is the hive's agent's to re-sign on the same branch. + c.info("stage labels: hive-authored adopted PR has unsigned commits on a head the sweep cannot rewrite; keeping it in place", "repo", obs.Display, "pr", obs.Number, "author", obs.Author, "head", obs.HeadSHA, "head_repo", obs.HeadRepo, "can_push", canPushInPlace) + } + if adoptedHeadNeedsDCORehome(obs, rec, canPushInPlace, hiveAuthored) { fence, err := c.adoptionDiffRefusal(ctx, obs) if fence != "" && (err != nil || adoptionFenceDefers(fence)) { // Not a verdict: the head moved, or its file list is @@ -1954,7 +1979,18 @@ func inPlaceRehomeReason(obs stageObservation, rec stagelabels.Record, policy St if !rec.AdoptedInPlace() || obs.HeadSHA == "" || obs.HeadSHA != rec.AdoptedHead || adoptedHeadDCORed(obs, rec) || adoptionBlocked(obs.Labels) != "" || verdictNeedsHuman(obs.Detail) { return "" } + if adoptionHeadApproved(obs) { + // A copy restarts CI and drops the approval; the head stays where + // the approval is. Only a fork the hive cannot push to re-homes + // (AdoptReasonPushRehome, decided by the caller). + return "" + } if adoptedHeadSignoffUnfixable(obs, rec) { + if hiveAuthoredPR(obs, policy, "") { + // The squash attributes the hive's commits to the hive's own + // author: nothing to re-home (hivecommons/hive#16619). + return "" + } return AdoptReasonSignoffRehome } if humanConflictReasons[obs.Reason] || humanConflictReasons[obs.LaneReason] || hasLabelFold(obs.Labels, "needs-rebase") { @@ -1992,7 +2028,7 @@ func adoptionStalledReasonWith(obs stageObservation, rec stagelabels.Record, pol if rec.AdoptionAttemptedNothingOpened(obs.HeadSHA) { return stagelabels.LaneReasonAdoptionStalledPrefix + "supersede-failed:" + nonEmpty(rec.AdoptReason, obs.Reason) } - if adoptedHeadSignoffUnfixable(obs, rec) { + if adoptedHeadSignoffUnfixable(obs, rec) && !hiveAuthoredPR(obs, policy, "") { return stagelabels.LaneReasonAdoptionStalledPrefix + stagelabels.LaneReasonHiveSignoffAttribution } if adoptionOptionalCheckOnly(obs) || !adoptionStale(obs, rec, policy, now) { @@ -2020,6 +2056,15 @@ func (c *Engine) escapeStalledAdoption(ctx context.Context, store *stagelabels.S rec, _ = store.Get(key) } rehomeReason := inPlaceRehomeReason(obs, rec, policy, now, c.inPlaceRebaseExhausted(obs, rec)) + if rehomeReason == AdoptReasonSignoffRehome && hiveAuthoredPR(obs, policy, c.transport.AppBotLogin()) { + rehomeReason = "" + } + if rehomeReason != "" && c.operatorAdmission(ctx, obs.Owner, obs.Repo, obs.Number, obs.HeadSHA) != "" { + // An operator admitted this head: a copy would drop that and + // restart CI. Only a fork the hive cannot push to re-homes. + c.info("stage labels: in-place adoption keeps its approved head; not superseding", "repo", obs.Display, "pr", obs.Number, "head", obs.HeadSHA, "would_rehome", rehomeReason) + rehomeReason = "" + } if rehomeReason == "" && rec.AdoptedInPlace() && obs.HeadSHA == rec.AdoptedHead && !adoptedHeadDCORed(obs, rec) && adoptionBlocked(obs.Labels) == "" && !verdictNeedsHuman(obs.Detail) && c.pushAccessLost(ctx, obs) { rehomeReason = AdoptReasonPushRehome } diff --git a/src/pkg/github/automerge/automerge_contributor_adopt_test.go b/src/pkg/github/automerge/automerge_contributor_adopt_test.go index 0d496bc52c..37a5043e98 100644 --- a/src/pkg/github/automerge/automerge_contributor_adopt_test.go +++ b/src/pkg/github/automerge/automerge_contributor_adopt_test.go @@ -586,45 +586,61 @@ func TestAdoptionDCORehomeDecisionAndRendering(t *testing.T) { Body: "Implements widgets.\n\nHive-Run: acme/widget#44\n", Detail: stageDetail{DCO: stagelabels.DCONo, DCOTotal: 3, DCOUnsigned: 2}, } - if !adoptionNeedsDCORehome(obs, false) { + if !adoptionNeedsDCORehome(obs, false, false) { t.Fatal("unsigned commits without branch push permission must re-home") } - if !adoptionNeedsDCORehome(obs, true) { + if !adoptionNeedsDCORehome(obs, true, false) { t.Fatal("unknown unsigned commit ownership must re-home") } obs.Detail.DCOUnsignedHive = 2 - if !adoptionNeedsDCORehome(obs, true) { + if !adoptionNeedsDCORehome(obs, true, false) { t.Fatal("a fork head must re-home even when only hive-authored commits are unsigned: the engine cannot rewrite a fork branch") } obs.Owner, obs.Repo, obs.HeadRepo = "acme", "widget", "acme/widget" - if adoptionNeedsDCORehome(obs, true) { + if adoptionNeedsDCORehome(obs, true, false) { t.Fatal("branch push permission with only hive-authored unsigned commits on a base-repo head allows in-place repair") } - if !adoptionNeedsDCORehome(obs, false) { + if !adoptionNeedsDCORehome(obs, false, false) { t.Fatal("hive-authored unsigned commits without branch push permission must still re-home") } inPlace := stagelabels.Record{AdoptedHead: "aaa", AdoptMode: stagelabels.AdoptModeInPlace} - if adoptedHeadNeedsDCORehome(obs, inPlace, true) { + if adoptedHeadNeedsDCORehome(obs, inPlace, true, false) { t.Fatal("already adopted in place with App-owned unsigned commits and push access stays in place") } - if !adoptedHeadNeedsDCORepair(obs, inPlace, true) { + if !adoptedHeadNeedsDCORepair(obs, inPlace, true, false) { t.Fatal("that head is the in-place repair's job") } obs.HeadRepo = "" - if !adoptedHeadNeedsDCORehome(obs, inPlace, true) { + if !adoptedHeadNeedsDCORehome(obs, inPlace, true, false) { t.Fatal("already adopted in place on a fork must re-home") } - if !adoptedHeadNeedsDCORehome(obs, inPlace, false) { + if !adoptedHeadNeedsDCORehome(obs, inPlace, false, false) { t.Fatal("already adopted in place without push access must re-home") } - if adoptedHeadNeedsDCORehome(obs, stagelabels.Record{AdoptedHead: "aaa", AdoptedBy: 90, AdoptMode: stagelabels.AdoptModeSupersede}, false) { + if adoptedHeadNeedsDCORehome(obs, stagelabels.Record{AdoptedHead: "aaa", AdoptedBy: 90, AdoptMode: stagelabels.AdoptModeSupersede}, false, false) { t.Fatal("a superseded adoption is never re-homed again") } obs.Detail.DCOUnsignedHive = 0 obs.Detail.DCOUnsigned = 0 - if adoptionNeedsDCORehome(obs, false) { + if adoptionNeedsDCORehome(obs, false, false) { t.Fatal("signed head does not need DCO re-home") } + // A hive-authored PR (hivecommons/hive#16619) is never re-homed for + // sign-off: a pushable base-repo head is amended in place whoever the + // unsigned commits are linked to; a fork head keeps its PR and waits. + own := obs + own.Author, own.Detail.DCOUnsigned, own.Detail.DCOUnsignedOther = "thatguywob", 2, 2 + own.Owner, own.Repo, own.HeadRepo = "acme", "widget", "acme/widget" + if got := adoptionDCORepairMode(own, true, true); got != stagelabels.AdoptModeInPlace { + t.Fatalf("hive-authored base-repo head: mode=%q, want in-place amend", got) + } + own.HeadRepo = "thatguywob/widget" + if got := adoptionDCORepairMode(own, false, true); got != "" { + t.Fatalf("hive-authored fork head: mode=%q, want no re-home", got) + } + if adoptionNeedsDCORehome(own, false, true) || adoptedHeadNeedsDCORehome(own, inPlace, false, true) { + t.Fatal("a hive-authored PR must never be superseded for sign-off") + } obs.Detail.DCOUnsigned = 2 body := AdoptionPRBody(obs, stagelabels.Record{Reason: "check-failing:dco"}, true, "") for _, want := range []string{ diff --git a/src/pkg/github/automerge/automerge_stage_dco.go b/src/pkg/github/automerge/automerge_stage_dco.go index 9729023de2..ec17c37b1b 100644 --- a/src/pkg/github/automerge/automerge_stage_dco.go +++ b/src/pkg/github/automerge/automerge_stage_dco.go @@ -7,6 +7,7 @@ import ( "strings" gh "github.com/google/go-github/v72/github" + "github.com/hivecommons/hive/pkg/authorkind" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -51,6 +52,16 @@ func dcoCommitStatsDetailed(commits []*gh.RepositoryCommit, appLogin string) dco } func dcoCommitStatsDetailedForAuthor(commits []*gh.RepositoryCommit, appLogin, prAuthor string) dcoStats { + return dcoCommitStatsForSquashAuthor(commits, appLogin, prAuthor, botSquashAuthor(prAuthor)) +} + +// dcoCommitStatsForSquashAuthor is dcoCommitStatsDetailedForAuthor with the +// squash-attribution verdict on the PR author made explicit: selfSquash means +// a squash under prAuthor attributes the hive's commits to the hive itself +// (a bot author, or one of this hive's own identities: project.ai_author, +// the App bot), so no signed hive commit is squash-unsafe. Unsigned commits +// are still counted and rejected. +func dcoCommitStatsForSquashAuthor(commits []*gh.RepositoryCommit, appLogin, prAuthor string, selfSquash bool) dcoStats { var stats dcoStats for _, rc := range commits { if rc == nil || len(rc.Parents) > 1 { @@ -65,7 +76,7 @@ func dcoCommitStatsDetailedForAuthor(commits []*gh.RepositoryCommit, appLogin, p } else { stats.unsignedOther++ } - } else if !botSquashAuthor(prAuthor) && dcoCommitByHive(rc, appLogin) && !messageHasPRAuthorSignoff(msg, prAuthor) { + } else if !selfSquash && dcoCommitByHive(rc, appLogin) && !messageHasPRAuthorSignoff(msg, prAuthor) { stats.squashUnsafeHive++ } } @@ -87,10 +98,12 @@ func dcoCommitByHive(commit *gh.RepositoryCommit, appLogin string) bool { // with Store.NoteDCO once the record exists). A read // failure leaves the state unknown (labels untouched, stage unchanged) and // is reported, never fatal. -func (c *Engine) stageDCO(ctx context.Context, store *stagelabels.Store, key string, obs stageObservation) (dcoStats, error) { +func (c *Engine) stageDCO(ctx context.Context, store *stagelabels.Store, key string, obs stageObservation, policy StageLabelPolicy) (dcoStats, error) { if obs.HeadSHA == "" { return dcoStats{}, nil } + appLogin := c.transport.AppBotLogin() + selfSquash := botSquashAuthor(obs.Author) || hiveAuthoredPR(obs, policy, appLogin) if rec, ok := store.Get(key); ok { if t, u, cached := rec.DCOFor(obs.HeadSHA); cached { // Records cached before the ownership split existed carry @@ -98,7 +111,7 @@ func (c *Engine) stageDCO(ctx context.Context, store *stagelabels.Store, key str // so read the commits once more for that case only. if (u > 0 || rec.DCOSquashUnsafeKnown) && (u == 0 || rec.DCOSplitKnown(obs.HeadSHA) || !rec.AdoptedInPlace()) { unsafe := rec.DCOSquashUnsafeHive - if botSquashAuthor(obs.Author) { + if selfSquash { unsafe = 0 } return dcoStats{total: t, unsigned: u, unsignedHive: rec.DCOUnsignedHive, unsignedOther: u - rec.DCOUnsignedHive, squashUnsafeHive: unsafe}, nil @@ -110,7 +123,27 @@ func (c *Engine) stageDCO(ctx context.Context, store *stagelabels.Store, key str if err != nil { return dcoStats{}, err } - return dcoCommitStatsDetailedForAuthor(all, c.transport.AppBotLogin(), obs.Author), nil + return dcoCommitStatsForSquashAuthor(all, appLogin, obs.Author, selfSquash), nil +} + +// hiveAuthoredPR reports whether the PR is the hive's own: author/hive by +// kind, observed under the self-authored lane, authored by the App bot, or +// authored by one of the identities the policy names as this hive's +// (project.ai_author — the clanker login the hive's agents open PRs as). +// Such a PR is never re-homed for sign-off attribution: a squash under its +// author attributes the hive's commits to the hive (hivecommons/hive#16619). +func hiveAuthoredPR(obs stageObservation, policy StageLabelPolicy, appLogin string) bool { + if obs.AuthorKind == authorkind.Hive || obs.Lane == stageLaneSelf { + return true + } + author := strings.TrimSpace(obs.Author) + if author == "" { + return false + } + if appLogin != "" && strings.EqualFold(author, appLogin) { + return true + } + return policy.HiveAuthor != nil && policy.HiveAuthor(author) } // Matches the bot-PR policy in check-squash-signoff-attribution.sh: a squash diff --git a/src/pkg/github/automerge/automerge_stage_labels.go b/src/pkg/github/automerge/automerge_stage_labels.go index 61cb4649a0..e4adeb5fa5 100644 --- a/src/pkg/github/automerge/automerge_stage_labels.go +++ b/src/pkg/github/automerge/automerge_stage_labels.go @@ -140,6 +140,12 @@ type StageLabelPolicy struct { // (dashboard.authorized_users). Their PRs, like author/human ones, are // never adopted (hivecommons/hive#15202). nil = unknown. OwnerAuthor func(login string) bool + // HiveAuthor reports whether login is one of this hive's own PR-authoring + // identities (project.ai_author, the App bot: hgithub.HiveIdentity). A + // squash of such a PR attributes the hive's commits to the hive itself, + // so a sign-off re-home never applies to it (hivecommons/hive#16619: + // the hive superseded its own clanker's approved PR). nil = unknown. + HiveAuthor func(login string) bool // SharedCIIncident returns the open [shared-ci] incident the PR // (repo "owner/name", number, head SHA) is deferred to, or 0. A red PR // deferred to one is kept out of 070/072 and never nudged @@ -1004,7 +1010,7 @@ func (c *Engine) ApplyStageLabels(ctx context.Context) (StageLabelResult, error) // zero record for the head would be served back if the // same head later stopped matching. var err error - stats, err = c.stageDCO(ctx, store, key, obs) + stats, err = c.stageDCO(ctx, store, key, obs, policy) if err != nil { c.warn("stage labels: dco commit check failed", "repo", obs.Display, "pr", obs.Number, "error", err) if firstErr == nil { diff --git a/src/pkg/github/automerge/shared_ci_attribution_test.go b/src/pkg/github/automerge/shared_ci_attribution_test.go index d3d5e83a99..1e20a6a6d3 100644 --- a/src/pkg/github/automerge/shared_ci_attribution_test.go +++ b/src/pkg/github/automerge/shared_ci_attribution_test.go @@ -45,7 +45,7 @@ func TestStageDCONormalizesCachedBotAttributionWithoutChangingSignoffs(t *testin store.NoteDCO(key, "aaa", 3, 0, 0, 1) got, err := e.stageDCO(context.Background(), store, key, stageObservation{ Owner: "acme", Repo: "widget", Number: 42, HeadSHA: "aaa", Author: "dependabot[bot]", - }) + }, StageLabelPolicy{}) if err != nil || got.total != 3 || got.unsigned != 0 || got.squashUnsafeHive != 0 { t.Fatalf("cached bot attribution: %+v, %v", got, err) } diff --git a/src/pkg/github/pr_request_signed.go b/src/pkg/github/pr_request_signed.go index 345884abb6..b46ab34604 100644 --- a/src/pkg/github/pr_request_signed.go +++ b/src/pkg/github/pr_request_signed.go @@ -150,6 +150,7 @@ func (c *Client) signBranch(ctx context.Context, owner, repo, base, head string) return "", 0, err } headline, body := signedCommitMessage(comparison.Commits) + body = ensureSignedOffBy(body, c.appBotLogin) // Scratch ref at the merge base. Delete a leftover from a crashed run // first: CreateRef 422s on an existing ref. @@ -384,6 +385,22 @@ func BotSignedOffByTrailer(login string) string { return "Signed-off-by: " + login + " <" + signedTrailerEmail(login+"@"+signedTrailerNoreplyDomain) + ">" } +// ensureSignedOffBy appends the App's own DCO trailer to a signed commit's +// body when none of the folded agent commits carried one. The commit is +// authored by the App bot, so an unsigned body would publish a hive-authored +// commit without sign-off (hivecommons/hive#16619); the trailer is the one +// BotSignedOffByTrailer derives, or nothing when the App login is unknown. +func ensureSignedOffBy(body, appLogin string) string { + if strings.TrimSpace(appLogin) == "" || signedTrailerLineRE.MatchString(body) { + return body + } + trailer := BotSignedOffByTrailer(appLogin) + if strings.TrimSpace(body) == "" { + return trailer + } + return strings.TrimRight(body, "\n") + "\n\n" + trailer +} + // signedTrailersBracketFree rewrites every Signed-off-by line in msg through // signedTrailerEmail, leaving the rest of the message byte-for-byte intact. func signedTrailersBracketFree(msg string) string { diff --git a/src/pkg/github/pr_request_signed_test.go b/src/pkg/github/pr_request_signed_test.go index ca82d8a6fc..f0fd9e42cc 100644 --- a/src/pkg/github/pr_request_signed_test.go +++ b/src/pkg/github/pr_request_signed_test.go @@ -536,6 +536,27 @@ func TestSignedCommitMessage(t *testing.T) { } } +// A signed re-author whose agent commits carried no trailer still publishes +// a signed-off commit (hivecommons/hive#16619); one that already has a +// trailer, or an unknown App login, is left as folded. +func TestEnsureSignedOffBy(t *testing.T) { + t.Setenv(signedTrailerDomainEnv, "") + want := "Signed-off-by: acme-hive[bot] " + if got := ensureSignedOffBy("body one\n\nsecond", "acme-hive[bot]"); got != "body one\n\nsecond\n\n"+want { + t.Errorf("unsigned body: got %q", got) + } + if got := ensureSignedOffBy("", "acme-hive[bot]"); got != want { + t.Errorf("empty body: got %q", got) + } + signed := "body\n\nSigned-off-by: a " + if got := ensureSignedOffBy(signed, "acme-hive[bot]"); got != signed { + t.Errorf("signed body must not gain a second trailer: got %q", got) + } + if got := ensureSignedOffBy("body", ""); got != "body" { + t.Errorf("unknown App login must not invent a trailer: got %q", got) + } +} + func TestGraphQLEndpoint(t *testing.T) { cases := map[string]string{ "https://api.github.com/": "https://api.github.com/graphql", diff --git a/src/pkg/github/push_branch_request_watcher.go b/src/pkg/github/push_branch_request_watcher.go index dd509f6929..73ec561179 100644 --- a/src/pkg/github/push_branch_request_watcher.go +++ b/src/pkg/github/push_branch_request_watcher.go @@ -405,6 +405,18 @@ func (c *Client) handleOnePushBranchRequest(ctx context.Context, path string, no } sha = strings.TrimSpace(sha) + // Every commit a hive identity authors must carry its sign-off before it + // leaves the checkout. An unsigned hive commit on a published branch is + // what later makes the automerge DCO stage re-author the PR + // (hivecommons/hive#16619); refusing it here keeps the fix at the source. + // Hooks are neutralised by pushBranchGitEnv, so the relay checks itself. + if log, err := pushBranchExec(ctx, req.Dir, env, "git", "log", "--no-merges", "--format="+unsignedHiveCommitFormat, sha, "--not", "--remotes"); err == nil { + if bad := unsignedHiveCommits(log, c.pushHiveIdentities()); len(bad) > 0 { + c.denyPushBranchRequest(path, req, fmt.Sprintf("commit %s is authored by hive identity %q without a Signed-off-by trailer; hive-authored commits must be signed off at creation (git commit -s)", bad[0].SHA, bad[0].Author), nowFn) + return + } + } + args := []string{"push"} if req.ForceWithLease { args = append(args, "--force-with-lease") @@ -493,3 +505,79 @@ func WritePushBranchRequest(dir string, req PushBranchRequest) (string, error) { } return path, nil } + +// unsignedHiveCommitFormat is the git log format unsignedHiveCommits parses: +// one record per commit, fields split by US (0x1f), records by RS (0x1e). +const unsignedHiveCommitFormat = "%H%x1f%an%x1f%ae%x1f%B%x1e" + +// unsignedHiveCommit names a commit the push relay refuses. +type unsignedHiveCommit struct { + SHA string + Author string +} + +// pushHiveIdentities lists the logins whose commits must be signed off: the +// App bot and the configured hive identity (ai_author + App login). +func (c *Client) pushHiveIdentities() []string { + var ids []string + if c.appBotLogin != "" { + ids = append(ids, c.appBotLogin) + } + id := c.getHiveIdentity() + ids = append(ids, id.AIAuthor, id.AppLogin) + return ids +} + +// unsignedHiveCommits parses `git log --format=unsignedHiveCommitFormat` +// output and returns the commits authored by one of logins (by name, or by a +// GitHub noreply / App-slug address) whose message has no Signed-off-by +// trailer. Commits by anyone else are not the relay's concern; the DCO check +// on the PR handles those. +func unsignedHiveCommits(log string, logins []string) []unsignedHiveCommit { + var bad []unsignedHiveCommit + for _, rec := range strings.Split(log, "\x1e") { + rec = strings.TrimSpace(rec) + if rec == "" { + continue + } + f := strings.SplitN(rec, "\x1f", 4) + if len(f) < 4 { + continue + } + sha, name, email, msg := strings.TrimSpace(f[0]), strings.TrimSpace(f[1]), strings.TrimSpace(f[2]), f[3] + login := hiveIdentityForCommitter(name, email, logins) + if login == "" || signedTrailerLineRE.MatchString(msg) { + continue + } + bad = append(bad, unsignedHiveCommit{SHA: sha, Author: login}) + } + return bad +} + +// hiveIdentityForCommitter returns the login in logins that name/email +// belongs to, or "" when the committer is not a hive identity. A login +// matches its own name, "@users.noreply.github.com", +// "+@users.noreply.github.com", and (for "[bot]") the +// bracket-free "@…" address signedTrailerEmail derives. +func hiveIdentityForCommitter(name, email string, logins []string) string { + email = strings.ToLower(email) + local := email + if i := strings.IndexByte(email, '@'); i >= 0 { + local = email[:i] + } + if i := strings.IndexByte(local, '+'); i >= 0 { + local = local[i+1:] + } + for _, login := range logins { + login = strings.TrimSpace(login) + if login == "" { + continue + } + slug := strings.TrimSuffix(login, "[bot]") + if strings.EqualFold(name, login) || strings.EqualFold(name, slug) || + strings.EqualFold(local, login) || strings.EqualFold(local, slug) { + return login + } + } + return "" +} diff --git a/src/pkg/github/push_branch_request_watcher_test.go b/src/pkg/github/push_branch_request_watcher_test.go index d8d2bd8898..2ca68f8ff8 100644 --- a/src/pkg/github/push_branch_request_watcher_test.go +++ b/src/pkg/github/push_branch_request_watcher_test.go @@ -99,10 +99,10 @@ func TestPushBranchRequestWatcher_PushesAndConsumes(t *testing.T) { if !resp.OK || resp.Branch != "scanner/fix-1" || resp.SHA != "cafe1234" { t.Errorf("result = %+v, want ok with branch and sha", resp) } - if len(*calls) != 2 { - t.Fatalf("git calls = %d, want rev-parse + push", len(*calls)) + if len(*calls) != 3 { + t.Fatalf("git calls = %d, want rev-parse + sign-off log + push", len(*calls)) } - push := (*calls)[1] + push := (*calls)[2] joined := strings.Join(push.args, " ") if push.dir != checkout || !strings.Contains(joined, "https://github.com/o/r.git") || @@ -136,10 +136,10 @@ func TestPushBranchRequestWatcher_ForceWithLease(t *testing.T) { } c.ProcessPushBranchRequestsOnce(context.Background()) - if len(*calls) != 2 { - t.Fatalf("git calls = %d, want 2", len(*calls)) + if len(*calls) != 3 { + t.Fatalf("git calls = %d, want 3", len(*calls)) } - if joined := strings.Join((*calls)[1].args, " "); !strings.Contains(joined, "--force-with-lease") || strings.Contains(joined, " --force ") { + if joined := strings.Join((*calls)[2].args, " "); !strings.Contains(joined, "--force-with-lease") || strings.Contains(joined, " --force ") { t.Errorf("push args = %q, want --force-with-lease and never a plain --force", joined) } } @@ -392,3 +392,60 @@ func TestPushBranchGitEnv_NoHeader(t *testing.T) { t.Errorf("env missing core.hooksPath override: %q", joined) } } + +// A branch carrying a hive-authored commit without a Signed-off-by trailer +// is refused before anything reaches GitHub (hivecommons/hive#16619); the +// same commit by an outside contributor is the PR DCO check's business. +func TestPushBranchRequestWatcher_RefusesUnsignedHiveCommit(t *testing.T) { + c := pushTestClient(t, "http://127.0.0.1:1") + c.SetHiveIdentity(HiveIdentity{AIAuthor: "thatguywob", AppLogin: "hivecommons-hive[bot]"}) + dir := withPushDir(t) + var calls []pushExecCall + old := pushBranchExec + pushBranchExec = func(_ context.Context, _ string, _ []string, name string, args ...string) (string, error) { + calls = append(calls, pushExecCall{args: append([]string{name}, args...)}) + switch args[0] { + case "rev-parse": + return "cafe1234\n", nil + case "log": + return "cafe1234\x1fthatguywob\x1fthatguywob@users.noreply.github.com\x1ffix: thing\n\nbody\n\x1e" + + "beef5678\x1fscanner\x1f280983584+hivecommons-hive[bot]@users.noreply.github.com\x1ffix: other\n\nSigned-off-by: scanner \n\x1e", nil + } + return "", nil + } + t.Cleanup(func() { pushBranchExec = old }) + + reqPath, err := WritePushBranchRequest(dir, PushBranchRequest{Repo: "o/r", Branch: "scanner/fix-3", Dir: t.TempDir(), Agent: "scanner"}) + if err != nil { + t.Fatal(err) + } + c.ProcessPushBranchRequestsOnce(context.Background()) + + resp := readPushBranchResult(t, reqPath) + if resp.OK || !strings.Contains(resp.Error, "cafe1234") || !strings.Contains(resp.Error, "thatguywob") || !strings.Contains(resp.Error, "Signed-off-by") { + t.Errorf("result = %+v, want a denial naming the unsigned hive commit", resp) + } + for _, call := range calls { + if call.args[1] == "push" { + t.Fatalf("unsigned hive commit was pushed: %v", call.args) + } + } + if _, err := os.Stat(reqPath + ".denied"); err != nil { + t.Errorf("denied request not parked: %v", err) + } +} + +func TestUnsignedHiveCommits(t *testing.T) { + logins := []string{"hivecommons-hive[bot]", "thatguywob"} + log := "a1\x1fthatguywob\x1fthatguywob@users.noreply.github.com\x1fsubject\n\x1e" + + "a2\x1fscanner\x1f280983584+hivecommons-hive[bot]@users.noreply.github.com\x1fsubject\n\x1e" + + "a3\x1fhivecommons-hive[bot]\x1fhivecommons-hive@hive.kubestellar.io\x1fsubject\n\nSigned-off-by: hivecommons-hive[bot] \n\x1e" + + "a4\x1fMallory\x1fmallory@example.com\x1fsubject\n\x1e" + got := unsignedHiveCommits(log, logins) + if len(got) != 2 || got[0].SHA != "a1" || got[0].Author != "thatguywob" || got[1].SHA != "a2" || got[1].Author != "hivecommons-hive[bot]" { + t.Errorf("unsignedHiveCommits = %+v, want a1 (ai_author) and a2 (App by noreply address) only", got) + } + if got := unsignedHiveCommits("", logins); len(got) != 0 { + t.Errorf("empty log flagged %+v", got) + } +} From bc23607077cdf7b7c25314e0fc77240989c5475b Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 14:35:25 -0500 Subject: [PATCH 08/24] =?UTF-8?q?=F0=9F=90=9B=20PR=20in=20progress=20chevr?= =?UTF-8?q?on=20defers=20to=20running=20CI/Review=20and=20never=20speaks?= =?UTF-8?q?=20the=20CI=20verdict=20(#16644)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 fix(dashboard): PR in progress chevron defers to running tracks, speaks only lifecycle Activation resolves CI and Review first: if either runs on the head the stage chevron (PR in progress, Merge queue …) renders settled-current and icon only, its words in the tooltip, so CI + Review is the one pair that can be active together and every other row has exactly one active chevron. The unpicked-up and owner-wait captions drop the red word ("Unassigned · next: scanner", "Waiting for @author · fix owed"; the external-PR fixing word reads "Fix owed · …"); the CI / review verdict stays in the detail. Prelude invariant over every row fixture: active set ⊆ {CI, Review} or size 1, and no stage chevron names a track verdict. Canonical rules documented in the Activity Monitor section. Fixes #16643 Signed-off-by: Andrew Anderson * 🐛 fix(dashboard): one fill for an active CI/Review chevron The darker amber the operator saw was .ham-activity-track.active.ham-stalled (a 55 % amber mix with --text) — the stalled-blocker fill from #16600 on rows where nothing moved (CI "not reported" / "no verdict yet" at 050). An active, text-bearing track now has exactly the .ham-seg.active fill; stalled keeps only its stillness and person glyph. Go CI Active follows the state (running / queued) regardless of poll freshness; the observation age rides ObservedAt for the tooltip. Invariants: every text-bearing track is plainly active (prelude over all fixtures), and no CSS rule restyles the active track background. Refs #16643 Signed-off-by: Andrew Anderson * test: run row-stamp harness over stdin to dodge the -e arg limit Refs #16643 Signed-off-by: Andrew Anderson --------- Signed-off-by: Andrew Anderson --- .../fixed-pr-progress-chevron-fallback.md | 1 + .../dashboard-sections/activity-monitor.md | 11 ++- src/pkg/dashboard/stage_tracker_activity.go | 13 +-- .../dashboard/stage_tracker_activity.test.js | 6 +- .../dashboard/stage_tracker_activity_test.go | 8 +- .../stage_tracker_collection_test.go | 6 +- .../dashboard/stage_tracker_motion_test.go | 4 +- .../dashboard/stage_tracker_remediation.go | 16 +++- .../stage_tracker_remediation_chevron.test.js | 79 ++++++++++++++++--- .../stage_tracker_remediation_test.go | 49 +++++++++++- .../stage_tracker_status_collection_test.go | 2 +- .../stage_tracker_ui_prelude_test.go | 16 ++++ .../dashboard/stage_tracker_ui_rows_test.go | 2 +- src/pkg/dashboard/static-src/css/tracker.css | 14 ++-- .../static-src/js/tracker-row-strip.js | 18 +++-- .../dashboard/static-src/js/tracker-row.js | 6 +- src/pkg/dashboard/static/index.html | 38 +++++---- 17 files changed, 229 insertions(+), 60 deletions(-) create mode 100644 changelog.d/fixed-pr-progress-chevron-fallback.md diff --git a/changelog.d/fixed-pr-progress-chevron-fallback.md b/changelog.d/fixed-pr-progress-chevron-fallback.md new file mode 100644 index 0000000000..0fc6a63580 --- /dev/null +++ b/changelog.d/fixed-pr-progress-chevron-fallback.md @@ -0,0 +1 @@ +- Activity Monitor: the PR in progress chevron is the row's fallback — it defers (settled, icon only) whenever CI or Review runs, so CI + Review is the only pair ever active together — and its words are the PR's lifecycle (`Unassigned · next: scanner`, `Waiting for @author · fix owed`), never the CI / review verdict — and an active CI / Review chevron has exactly one fill: the stalled-blocker track no longer renders a darker amber, and running checks stay active whatever the poll's age (hivecommons/hive#16643). diff --git a/src/docs/dashboard-sections/activity-monitor.md b/src/docs/dashboard-sections/activity-monitor.md index ed0faa99a2..e183c196de 100644 --- a/src/docs/dashboard-sections/activity-monitor.md +++ b/src/docs/dashboard-sections/activity-monitor.md @@ -82,7 +82,7 @@ At 090 the row explains why: `· workflow files`, `· tests removed`, `· manual A verified merge from the canonical merge ledger is terminal whether Hive, a maintainer or another bot performed it. The last known root or linked PR model reaches **Merged** during the existing short terminal/pin window, even without an earlier queue observation. The comment names the actual recorded merger; an unknown actor stays unknown. This does not invent an earlier queue/admission state or close a merely related issue. A stale open refresh cannot undo a verified merge, and repeated delivery or later actor enrichment does not replay the merge or restart its window. Terminal visibility does not re-enable closed-PR actions. -A failing external PR without a recorded Hive stage actor remains **CI failing · author-owned** when its PR author is known, **CI failing · owner recorded** for an observed claimant, or **CI failing · owner unknown** otherwise. Its work activity is unknown; missing internal worker evidence is not evidence that nobody is working. Inline and nested rows use the PR author or claimant, not the related issue's filer or holder. Explicit unclaimed Hive/bot routing and real CI failures remain unchanged. +A failing external PR without a recorded Hive stage actor remains **Fix owed · author-owned** when its PR author is known, **Fix owed · owner recorded** for an observed claimant, or **Fix owed · owner unknown** otherwise (the red verdict itself is the CI chevron's word, never this lane's). Its work activity is unknown; missing internal worker evidence is not evidence that nobody is working. Inline and nested rows use the PR author or claimant, not the related issue's filer or holder. Explicit unclaimed Hive/bot routing and real CI failures remain unchanged. - With no covering PR, an issue has a full strip lit at Open, Actionable or Claimed. - With exactly one covering PR, issue and PR share one continuous strip; early issue steps are passed and the PR supplies the current stage, chip, tooltip and age. @@ -431,6 +431,15 @@ The *state pill* says where the item is and what it is waiting on (`hold`, `need Plain words throughout — working / waiting on X / set back by Y / merged — nothing else blinks. +#### Chevron activation — the canonical rules + +An *active* chevron is filled amber and carries words; an inactive one is its icon alone (CI / Review: the ring, green when the last run on this head passed, red when it failed, neutral when not yet run), with the counts in its tooltip. On every strip: + +1. **1 ≤ active ≤ 2.** At least one chevron is active — the column where the item is or where it is stuck. +2. **CI and Review resolve first.** A track is active only while it genuinely runs on the current head (a check-run in progress or queued, a ring not yet full; a reviewer running or queued). If either runs, the PR is waiting on it: the stage chevron (PR in progress, Merge queue …) renders settled-current — filled but still, icon only, its words in the tooltip — and nothing else is active. +3. **CI + Review is the only pair.** Two chevrons are active together only when both tracks run at once; every other combination is exactly one active chevron. The stage chevron is the ≥ 1 fallback: active only when no track is in motion. +4. **The PR in progress chevron speaks the PR's lifecycle** — draft, pushed, rebasing, *Unassigned · next: scanner*, *Waiting for @author · fix owed* — never a CI or review verdict. *CI failing*, *CI 4/11 · 1 failing* and *changes requested* are the CI and Review chevrons' words; the PR in progress tooltip keeps the red reason as detail. + #### The row's lead action, inline A row whose next move is yours does not hide its answer behind three dots. Beside the chips on the right of the header (and on a nested PR sub-row's own header), the row renders its **lead action** as a real `` : ''}${info.url ? `Open on GitHub` : ''}
    `; + el.innerHTML = `
    ${repoChip ? repoChip + ' ' : ''}${num ? `#${esc(num)} ` : ''}merged${t.merger ? ` by ${esc(t.merger)}` : ''}${info.preview ? ' (test)' : ''}
    ${esc(t.text)}
    `; box.appendChild(el); while (box.children.length > STAGE_TRACKER_MERGE_BANNER_MAX) { toastCountdownCancel(box.children[0]); box.children[0].remove(); } toastCountdownBar(el, stageTrackerMergeBannerMs(), () => stageTrackerMergeBannerDismiss(el)); diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index fc37d9d95e..f3aa9ca177 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -2062,6 +2062,7 @@ .merge-banner-ico { color: var(--green); font-weight: var(--fw-bold); } .merge-banner-head { font-weight: var(--fw-semibold); } .merge-banner-head .merge-banner-num { color: var(--amber); font-variant-numeric: tabular-nums; } + .merge-banner-head .merge-banner-by { font-weight: 500; } .merge-banner-text { margin-top: var(--sp-1); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .merge-banner-links { margin-top: var(--sp-2); display: flex; gap: var(--sp-4); font-size: var(--fs-xs); } .merge-banner-links button, .merge-banner-links a { border: 0; padding: 0; background: transparent; color: var(--accent); cursor: pointer; font: inherit; text-decoration: none; } @@ -25043,7 +25044,11 @@

    All labels

    // no count — instead of letting the row vanish in silence. const closed = stageTrackerNewlyClosed(d, _stageTrackerMergeState, next, _stageTrackerPRItems, _stageTrackerClosedNoted); const closedItems = closed.map(k => prevItems[k] || _stageTrackerPRLast[k]); - closed.forEach(k => { _stageTrackerClosedNoted[k] = true; delete next[k]; delete _stageTrackerPRLast[k]; }); + // The closed key stays comparable (false), not deleted: a close the + // server later corrects to a merge — a bot's comment on a just-merged + // PR read as "closed" before the merge fact landed — still flips + // false → true and celebrates (hivecommons/hive#16658). + closed.forEach(k => { _stageTrackerClosedNoted[k] = true; delete _stageTrackerPRLast[k]; }); _stageTrackerMergeState = next; // A merged PR is no longer in this payload, so its last host survives. if (typeof stageTrackerPRHosts === 'function') Object.assign(_stageTrackerPRHost, stageTrackerPRHosts(d)); @@ -25411,6 +25416,30 @@

    All labels

    if (!by) return ''; return by === 'hive' ? 'by hive' : 'by @' + by; } + // Pure: the merger as the merge toast's head names them — "🐝 hive" + // for the hive's own merge, "@login" for anyone else, '' unknown. + function stageTrackerMergerText(by) { + by = String(by || '').trim(); + if (!by) return ''; + return by === 'hive' ? '🐝 hive' : '@' + by; + } + // Pure: who merged the PR at key, from the payload's terminal facts — + // recently_merged (audit + ledger, any merger) and the ledger's recent + // list — then the terminal fact this tab already holds. '' unknown. + function stageTrackerMergedByOf(key, d) { + const n = Number(String(key || '').slice(String(key || '').lastIndexOf('/pr#') + 4)) || 0; + const repo = String(key || '').slice(0, String(key || '').lastIndexOf('/pr#')).toLowerCase(); + if (!n || !repo) return ''; + const short = repo.slice(repo.lastIndexOf('/') + 1); + const ledger = d && d.merged && Array.isArray(d.merged.recent) ? d.merged.recent : []; + for (const m of (d && Array.isArray(d.recently_merged) ? d.recently_merged : []).concat(ledger)) { + if (!m || Number(m.number) !== n || !m.merged_by) continue; + const r = String(m.repo || '').toLowerCase(); + if (r === repo || (r.indexOf('/') < 0 && r === short)) return String(m.merged_by).trim(); + } + const fact = typeof _stageTrackerTerminalFacts !== 'undefined' && _stageTrackerTerminalFacts ? _stageTrackerTerminalFacts[key] : null; + return fact && fact.merged_by ? String(fact.merged_by).trim() : ''; + } // Pure: the popover's inner HTML. function stageTrackerMergedPopHtml(txt, nowMs) { const fmtAt = at => { if (!at) return ''; const d = new Date(at); const sameDay = stageTrackerLocalMidnight(at) === stageTrackerLocalMidnight(nowMs); const hm = `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`; return sameDay ? hm : `${typeof formatDashboardDate === 'function' ? formatDashboardDate(d, { month: 'short', day: 'numeric' }) : d.toISOString().slice(5, 10)} ${hm}`; }; @@ -25923,7 +25952,7 @@

    All labels

    const banner = stageTrackerMergeBanner({ key, rowKey, number, repo: key.slice(0, key.indexOf('/pr#')), at: now }); setTimeout(() => { const row = rowKey && el ? el.querySelector(`[data-ham-key="${CSS.escape(rowKey)}"]`) : null; - if (row) celebrateRow(row, { kind: 'merged', key, number, merged_by: fact && fact.merged_by }); + if (row) celebrateRow(row, { kind: 'merged', key, number, merged_by: (fact && fact.merged_by) || stageTrackerMergedByOf(key, typeof _stageTracker !== 'undefined' ? _stageTracker : null) }); else celebrateDetached(key, banner); }, i * STAGE_TRACKER_CELEBRATE_STAGGER_MS); }); @@ -26075,13 +26104,17 @@

    All labels

    const url = String(b.url || (b.pr && b.pr.url) || '').match(/^https:\/\/github\.com\/([^/]+\/[^/]+)\/pull\/\d+(?:[?#].*)?$/); return url ? url[1] : repo; } + // The head names the merger whoever they are — "#16644 merged by + // @clubanderson", "#16645 merged by 🐝 hive" — a merge by hand is + // celebrated exactly like the hive's own (hivecommons/hive#16658). function stageTrackerMergeBannerText(b, nowMs) { const d = new Date(b.at || nowMs); const hm = `${String(d.getHours()).padStart(2, '0')}:${String(d.getMinutes()).padStart(2, '0')}`; const who = stageTrackerMergedByText(b.merged_by); + const merger = stageTrackerMergerText(b.merged_by); const paren = [b.lane || '', who, hm].filter(Boolean).join(', '); const num = stageTrackerMergeBannerNumber(b); - return { number: num, head: `${num ? '#' + num + ' ' : ''}merged${b.preview ? ' (test)' : ''}`, text: `${b.title || b.repo || ''}${paren ? ' (' + paren + ')' : ''}`.trim() }; + return { number: num, merger, head: `${num ? '#' + num + ' ' : ''}merged${merger ? ' by ' + merger : ''}${b.preview ? ' (test)' : ''}`, text: `${b.title || b.repo || ''}${paren ? ' (' + paren + ')' : ''}`.trim() }; } // Stateful: a persistent banner, bottom right, for one merge — stays // until dismissed or stageTrackerMergeBannerMs() (twice the info toast @@ -26097,6 +26130,7 @@

    All labels

    const repo = stageTrackerMergeBannerRepo(b); const recent = repo ? ((_stageTrackerMerged.server && _stageTrackerMerged.server.recent) || []).find(e => stageTrackerMergeBannerRepo(e).toLowerCase() === repo.toLowerCase() && stageTrackerMergeBannerNumber(e) === stageTrackerMergeBannerNumber(b)) : null; const info = Object.assign({ title: _stageTrackerPRTitle[b.key] || '', merged_by: '', lane: '', url: '' }, recent || {}, b, { repo }); + if (!info.merged_by && !b.preview) info.merged_by = stageTrackerMergedByOf(b.key, typeof _stageTracker !== 'undefined' ? _stageTracker : null); const num = stageTrackerMergeBannerNumber(info); const repoChip = stageTrackerRepoChipHtml(repo, { repoChips: { primary: stageTrackerPrimaryRepo(), active: _stageTrackerFilter.repo } }); // A live merge the ledger has not listed yet still links: the key carries owner/name. @@ -26106,7 +26140,7 @@

    All labels

    el.className = 'merge-banner'; el.setAttribute('role', 'status'); if (b.rowKey) el.setAttribute('data-ham-row', b.rowKey); - el.innerHTML = `
    ${repoChip ? repoChip + ' ' : ''}${num ? `#${esc(num)} ` : ''}merged${info.preview ? ' (test)' : ''}
    ${esc(t.text)}
    `; + el.innerHTML = `
    ${repoChip ? repoChip + ' ' : ''}${num ? `#${esc(num)} ` : ''}merged${t.merger ? ` by ${esc(t.merger)}` : ''}${info.preview ? ' (test)' : ''}
    ${esc(t.text)}
    `; box.appendChild(el); while (box.children.length > STAGE_TRACKER_MERGE_BANNER_MAX) { toastCountdownCancel(box.children[0]); box.children[0].remove(); } toastCountdownBar(el, stageTrackerMergeBannerMs(), () => stageTrackerMergeBannerDismiss(el)); diff --git a/src/pkg/dashboard/webhook_tracker_refresh.go b/src/pkg/dashboard/webhook_tracker_refresh.go index c7a6e4db62..45be82106a 100644 --- a/src/pkg/dashboard/webhook_tracker_refresh.go +++ b/src/pkg/dashboard/webhook_tracker_refresh.go @@ -397,6 +397,7 @@ func (s *Server) applyWebhookItemSnapshots(snaps []github.WebhookItemSnapshot) i return 0 } s.recordMergedSnapshots(snaps) + s.forgetClosedSnapshots(snaps) s.noteClosedSnapshots(snaps) s.notePushedSnapshots(snaps) if s.deps != nil && s.deps.ApplyWebhookItems != nil { diff --git a/src/pkg/github/webhook_cache.go b/src/pkg/github/webhook_cache.go index 0c8d18ae94..5835d8137d 100644 --- a/src/pkg/github/webhook_cache.go +++ b/src/pkg/github/webhook_cache.go @@ -704,6 +704,25 @@ func webhookIssueDirtyTarget(event string, p webhookEventPayload) (int, bool) { return 0, false } +// webhookIssuePullRequestMerged reads the merge instant the `issue` object +// of an `issues` / `issue_comment` delivery carries for a pull request +// (`issue.pull_request.merged_at`). A bot's comment on a PR that just +// merged used to produce a closed-but-not-merged snapshot — the tracker +// then listed the merged PR in recently_closed and the SPA said "closed", +// forfeiting the merge celebration (hivecommons/hive#16658). +func webhookIssuePullRequestMerged(raw *json.RawMessage) bool { + if raw == nil || len(*raw) == 0 { + return false + } + var pr struct { + MergedAt *time.Time `json:"merged_at"` + } + if err := json.Unmarshal(*raw, &pr); err != nil { + return false + } + return pr.MergedAt != nil && !pr.MergedAt.IsZero() +} + // webhookItemHint is the payload's state for the issue or pull request an // `issues`, `issue_comment` or `pull_request*` delivery embeds; nil when the // event carries neither object. @@ -723,7 +742,8 @@ func webhookItemHint(event string, p webhookEventPayload) *WebhookItemHint { if p.Issue == nil || p.Issue.Number <= 0 { return nil } - h := &WebhookItemHint{Number: p.Issue.Number, IsPR: p.Issue.PullRequest != nil, State: p.Issue.State} + h := &WebhookItemHint{Number: p.Issue.Number, IsPR: p.Issue.PullRequest != nil, State: p.Issue.State, + Merged: webhookIssuePullRequestMerged(p.Issue.PullRequest)} if p.Issue.UpdatedAt != nil { h.UpdatedAt = *p.Issue.UpdatedAt } diff --git a/src/pkg/github/webhook_issue_pr_merged_test.go b/src/pkg/github/webhook_issue_pr_merged_test.go new file mode 100644 index 0000000000..660e4a9dfa --- /dev/null +++ b/src/pkg/github/webhook_issue_pr_merged_test.go @@ -0,0 +1,42 @@ +package github + +import ( + "encoding/json" + "testing" + "time" +) + +// TestWebhookItemHintIssueCommentOnMergedPR (hivecommons/hive#16658): +// an issues / issue_comment delivery on a pull request reads the merge +// from issue.pull_request.merged_at, so a bot's comment on a PR that just +// merged is a merged hint, not a closed-unmerged one; an open PR's null +// merged_at and a plain issue stay unmerged. +func TestWebhookItemHintIssueCommentOnMergedPR(t *testing.T) { + at := time.Date(2026, 10, 20, 19, 35, 26, 0, time.UTC) + for _, tc := range []struct { + name string + body string + isPR bool + merged bool + }{ + {"merged PR", `{"issue":{"number":16644,"state":"closed","pull_request":{"url":"u","merged_at":"2026-10-20T19:35:26Z"}}}`, true, true}, + {"open PR", `{"issue":{"number":16644,"state":"open","pull_request":{"url":"u","merged_at":null}}}`, true, false}, + {"closed unmerged PR", `{"issue":{"number":16644,"state":"closed","pull_request":{"url":"u"}}}`, true, false}, + {"issue", `{"issue":{"number":16644,"state":"closed"}}`, false, false}, + } { + var p webhookEventPayload + if err := json.Unmarshal([]byte(tc.body), &p); err != nil { + t.Fatal(err) + } + for _, event := range []string{"issue_comment", "issues"} { + h := webhookItemHint(event, p) + if h == nil || h.Number != 16644 || h.IsPR != tc.isPR || h.Merged != tc.merged { + t.Errorf("%s/%s: hint = %+v, want is_pr=%v merged=%v", tc.name, event, h, tc.isPR, tc.merged) + } + } + } + raw := json.RawMessage(`{"merged_at":"` + at.Format(time.RFC3339) + `"}`) + if !webhookIssuePullRequestMerged(&raw) || webhookIssuePullRequestMerged(nil) { + t.Fatal("webhookIssuePullRequestMerged: want true for a merge instant, false for no object") + } +} From 8b824c4aeeade8d8287ced751da108755bc8d67f Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 17:25:23 -0500 Subject: [PATCH 19/24] =?UTF-8?q?=F0=9F=90=9B=20Stage=20tracker:=20say=20C?= =?UTF-8?q?I=20running=20(not=20activity=20unknown)=20when=20checks=20are?= =?UTF-8?q?=20still=20pending=20(#16637)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 Stage tracker: say CI running (not activity unknown) when checks are still pending A head with 7/11 checks reported is mid-pipeline, not unknown: when checks still run or queue, the CI state is running (or queued) and the caption counts the unfinished checks; a required check with no run yet is one sentence in Detail instead of the missing verdict, and head-wide counts (required set unknown) follow the same rule. "no check results observed" is reserved for a head with zero check runs. The chevron word drops "no verdict yet" / bare "running" for the unfinished count or names, and the tooltip composes distinct facts once. Fixes #16630 Signed-off-by: Andrew Anderson * 🐛 Stage tracker: single-quote check names in CI captions and chevron text Signed-off-by: Andrew Anderson --------- Signed-off-by: Andrew Anderson Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-ci-activity-unknown-caption.md | 1 + src/pkg/dashboard/stage_tracker_activity.go | 143 ++++++++++++++---- .../dashboard/stage_tracker_activity.test.js | 80 +++++++--- .../dashboard/stage_tracker_activity_test.go | 141 +++++++++++++++-- .../stage_tracker_remediation_chevron.test.js | 22 +-- .../dashboard/stage_tracker_ui_rows_test.go | 10 +- .../static-src/js/tracker-row-strip.js | 54 +++++-- src/pkg/dashboard/static/index.html | 54 +++++-- 8 files changed, 399 insertions(+), 106 deletions(-) create mode 100644 changelog.d/fixed-ci-activity-unknown-caption.md diff --git a/changelog.d/fixed-ci-activity-unknown-caption.md b/changelog.d/fixed-ci-activity-unknown-caption.md new file mode 100644 index 0000000000..056a4e8cfa --- /dev/null +++ b/changelog.d/fixed-ci-activity-unknown-caption.md @@ -0,0 +1 @@ +- Activity Monitor stage tracker: a PR head whose checks are still reporting now reads `CI running · 4 checks pending` (chevron `CI 7/11 · 4 running`, or the last one or two unfinished names) instead of `CI activity unknown · last observed missing` / `CI unknown · no check results observed` / `no verdict yet`; a required check with no run while others still execute is one sentence in the tooltip rather than the "missing" verdict; the "no check results observed" wording is reserved for a head with zero check runs; and the chevron tooltip states each fact once (count word, detail sentence, head, source, observation time) instead of repeating the unreported check four times (#16630). Check names embedded in captions and chevron text are wrapped in single quotes. diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index 0302221485..dcefe29406 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -39,6 +39,10 @@ type StageTrackerActivity struct { ChecksTotal int `json:"checks_total,omitempty"` ChecksFailed int `json:"checks_failed,omitempty"` ChecksFailing []string `json:"checks_failing,omitempty"` + // ChecksPending names the counted checks with no final result yet + // (running, queued, or not reported), so the chevron can name the last + // one or two the head waits on (hivecommons/hive#16630). + ChecksPending []string `json:"checks_pending,omitempty"` // Perspective counts on the current head for the Review track: Total is // the swarm's expected set for this PR (configured perspectives plus any // extra one dispatched or reported for the head), Done the ones with a @@ -81,7 +85,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA } if !a.RequiredKnown || a.RequiredSource == "" || len(a.RequiredChecks) == 0 || len(a.Required) == 0 { stageTrackerCountHeadChecks(out, a) - stageTrackerHeadChecksMotion(out, a) + out.Active = out.State == "running" return out } type requiredObservation struct { @@ -117,7 +121,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA } if !found { stageTrackerCountHeadChecks(out, a) - stageTrackerHeadChecksMotion(out, a) + out.Active = out.State == "running" return out } } @@ -191,7 +195,10 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA // red, unreported or ambiguous its neighbours are — a ring that is not // yet full is a running ring, so the chevron stays active with its // count (hivecommons/hive#16631). The red names ride in ChecksFailing. + // Runs held behind the approve-workflows gate keep the waiting state, + // since only a person's click moves them (hivecommons/hive#16599). switch { + case out.State == "missing" && a.WorkflowApproval != nil && a.WorkflowApproval.Pending > 0: case running: out.State, out.Blocker = "running", "" case queued && out.State != "queued": @@ -205,6 +212,7 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA } total := len(a.Required) out.ChecksTotal = total + var unreported []string for _, name := range a.Required { switch perName[name] { case "passing": @@ -212,9 +220,26 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA case "failing": out.ChecksFailed++ out.ChecksFailing = append(out.ChecksFailing, name) - } - } - check := fmt.Sprintf("%q", out.Blocker) + case "missing": + unreported = append(unreported, name) + out.ChecksPending = append(out.ChecksPending, name) + case "skipped": + default: + out.ChecksPending = append(out.ChecksPending, name) + } + } + // A required check that has not reported while others on the same + // head still run or queue is not "missing": the head is mid-pipeline + // and its workflow is usually just later in the fan-out. The state is + // the motion; the unreported name rides in Detail (hivecommons/hive#16630). + // Runs held behind the approve-workflows gate keep the waiting state, + // since only a person's click moves them. + if out.State == "running" || out.State == "queued" { + if since := stageTrackerLatestCheckTime(a); since != nil { + out.Since = since + } + } + check := stageTrackerCheckName(out.Blocker) switch out.State { case "passing": out.Caption = "CI green · all " + plural(total, "required check") + " passed" @@ -223,13 +248,22 @@ func stageTrackerCIActivity(pr github.PullRequest, now time.Time) *StageTrackerA out.Caption = "CI failing · " + check + " red" out.Detail = "Required check " + check + " finished without success (failed, timed out, was cancelled, or needs action) on the PR's current commit. A fix or a re-run has to turn it green before CI can pass." case "running": - out.Caption = fmt.Sprintf("CI running · %d/%d checks done", done, total) + out.Caption = "CI running · " + stageTrackerPendingChecksWord(out.ChecksPending) out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are still executing or waiting for a runner on the PR's current commit.", done, plural(total, "required check")) + if len(unreported) > 0 { + out.Detail += " " + stageTrackerUnreportedChecksSentence(unreported) + } if out.ChecksFailed > 0 { out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed) out.Detail += fmt.Sprintf(" %s already red: %s.", plural(out.ChecksFailed, "required check"), strings.Join(out.ChecksFailing, ", ")) } case "queued": + if len(unreported) > 0 { + out.Blocker = "" + out.Caption = "CI queued · " + stageTrackerPendingChecksWord(out.ChecksPending) + out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are waiting for a runner on the PR's current commit. %s", done, plural(total, "required check"), stageTrackerUnreportedChecksSentence(unreported)) + break + } out.Caption = "CI queued · " + check + " waiting for a runner" out.Detail = "Required check " + check + " has been requested for the PR's current commit but has not started executing yet." case "missing": @@ -288,7 +322,10 @@ func pluralVerb(n int, one, many string) string { // stageTrackerCountHeadChecks fills the check counts from every check run // observed on the head when the required set is not known: one entry per // check name, red if any run of that name is red, green only if its latest -// run succeeded. +// run succeeded. The state follows the count (hivecommons/hive#16630): red +// when any name is red, running while names still lack a final result, +// and unknown — "no check results observed" — only when the head has no +// check run at all. func stageTrackerCountHeadChecks(out *StageTrackerActivity, a *github.PRCIActivity) { type tally struct { passing, failing bool @@ -327,39 +364,87 @@ func stageTrackerCountHeadChecks(out *StageTrackerActivity, a *github.PRCIActivi out.ChecksFailing = append(out.ChecksFailing, name) case t.passing: out.ChecksPassed++ + default: + out.ChecksPending = append(out.ChecksPending, name) } } + if out.ChecksTotal == 0 { + return + } + out.Since = stageTrackerLatestCheckTime(a) + observed := plural(out.ChecksTotal, "check") + " observed on the head" + unknownSet := "hive has not seen which checks branch protection requires" + switch { + case len(out.ChecksPending) > 0: + // Motion leads: a ring that is not full is running, however red + // its neighbours (hivecommons/hive#16631); the red names ride in + // ChecksFailing and the caption. + out.State = "running" + out.Caption = "CI running · " + stageTrackerPendingChecksWord(out.ChecksPending) + out.Detail = fmt.Sprintf("%d of the %s have a final result; the rest are still executing or waiting for a runner on the PR's current commit. %s, so every check on the head counts.", out.ChecksPassed+out.ChecksFailed, observed, unknownSet) + if out.ChecksFailed > 0 { + out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed) + out.Detail += fmt.Sprintf(" %s already red: %s.", plural(out.ChecksFailed, "check"), strings.Join(out.ChecksFailing, ", ")) + } + case out.ChecksFailed > 0: + // Fail closed to unknown, never to a verdict, without the required + // set — but the caption carries the red name. + out.Blocker = out.ChecksFailing[0] + out.Caption = "CI unknown · " + stageTrackerCheckName(out.ChecksFailing[0]) + " red · required set unknown" + out.Detail = fmt.Sprintf("%s of the %s finished without success on the PR's current commit, but %s, so it cannot tell whether the red check gates the merge.", plural(out.ChecksFailed, "check"), observed, unknownSet) + default: + out.Caption = fmt.Sprintf("CI unknown · all %s passed · required set unknown", observed) + out.Detail = fmt.Sprintf("Every check run observed on the PR's current commit succeeded, but %s, so it cannot call CI green.", unknownSet) + } } -// stageTrackerHeadChecksMotion turns the required-set-unknown count into a -// running track while any check run on the head is still executing or -// queued: the ring is not full, so the chevron must be active with its -// count rather than a silent part-green glyph (hivecommons/hive#16631). -func stageTrackerHeadChecksMotion(out *StageTrackerActivity, a *github.PRCIActivity) { - moving := 0 +// stageTrackerLatestCheckTime is the newest timestamp of any check run or +// commit status on the activity's head: the last moment CI was seen moving. +func stageTrackerLatestCheckTime(a *github.PRCIActivity) *time.Time { + var latest *time.Time for _, check := range a.Checks { if check.Head != "" && !strings.EqualFold(check.Head, a.Head) { continue } - switch check.State { - case "in_progress", "queued", "waiting", "pending", "requested": - moving++ + if check.Since != nil && (latest == nil || check.Since.After(*latest)) { + latest = check.Since } } - if moving == 0 { - return - } - done := out.ChecksTotal - moving - if done < 0 { - done = 0 - } - out.State, out.Blocker = "running", "" - out.Caption = fmt.Sprintf("CI running · %d/%d checks done", done, out.ChecksTotal) - out.Detail = fmt.Sprintf("%d of the %s observed on the PR's current commit have a final result; the rest are still executing or waiting for a runner. Which of them branch protection requires is not yet known.", done, plural(out.ChecksTotal, "check")) - if out.ChecksFailed > 0 { - out.Caption += fmt.Sprintf(" · %d failing", out.ChecksFailed) + return latest +} + +// stageTrackerCheckName is a CI job / check name as it reads inside +// caption, detail and chevron text: wrapped in single quotes, so a name +// stands apart from the words around it ('test' not reported). +func stageTrackerCheckName(name string) string { + return "'" + name + "'" +} + +// stageTrackerPendingChecksNamed is the most pending check names the +// caption spells out; beyond it the count speaks. +const stageTrackerPendingChecksNamed = 2 + +// stageTrackerPendingChecksWord: `'test' pending`, `'lint', 'test' pending`, +// or "54 checks pending". +func stageTrackerPendingChecksWord(pending []string) string { + if n := len(pending); n > 0 && n <= stageTrackerPendingChecksNamed { + quoted := make([]string, 0, n) + for _, name := range pending { + quoted = append(quoted, stageTrackerCheckName(name)) + } + return strings.Join(quoted, ", ") + " pending" } - out.Active = true + return plural(len(pending), "check") + " pending" +} + +// stageTrackerUnreportedChecksSentence names the required checks with no +// run on the head, once, for the Detail of a running or queued head. +func stageTrackerUnreportedChecksSentence(names []string) string { + quoted := make([]string, 0, len(names)) + for _, name := range names { + quoted = append(quoted, stageTrackerCheckName(name)) + } + return fmt.Sprintf("Required %s %s %s not reported for this head yet.", pluralVerb(len(names), "check", "checks"), strings.Join(quoted, ", "), pluralVerb(len(names), "has", "have")) } // stageTrackerExpectedPerspectives is the swarm's perspective set for this diff --git a/src/pkg/dashboard/stage_tracker_activity.test.js b/src/pkg/dashboard/stage_tracker_activity.test.js index 12b2c673c8..3aa547d240 100644 --- a/src/pkg/dashboard/stage_tracker_activity.test.js +++ b/src/pkg/dashboard/stage_tracker_activity.test.js @@ -27,7 +27,7 @@ function constLine(source, name) { assert.ok(match, 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 trackConsts = ['STAGE_TRACKER_WORKFLOW_APPROVAL_BLOCKER', 'STAGE_TRACKER_PENDING_CHECKS_NAMED', '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 = ['stageTrackerHiveOwesReReview', 'stageTrackerTrackLead', 'stageTrackerWaitingOnPerson', 'stageTrackerTrackRunning', 'stageTrackerWorkflowApprovalPending', 'stageTrackerRingSvg', 'stageTrackerStalledTrack', 'stageTrackerQueueAheadWord', 'stageTrackerStageTrack', 'stageTrackerHiveOwnsRepair', 'stageTrackerTrackWord', 'stageTrackerAgoWord', '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;')(); @@ -458,7 +458,7 @@ test('browser probes require a dedicated preview and cannot count offscreen head }); test('Hotshot #344 shape: queued CI and approved review retain current phase without pretending work runs', () => { - const item = livePR({ stage: 60, ci_activity: activity('queued', 'CI queued · "build" waiting for a runner'), review_activity: activity('approved', 'Review approved') }); + const item = livePR({ stage: 60, ci_activity: activity('queued', "CI queued · 'build' waiting for a runner"), review_activity: activity('approved', 'Review approved') }); const before = JSON.stringify(item); const cells = physicalTracks(item); assert.match(cells.ci, /ham-activity-track active ham-current/, 'queued CI is in progress: the full active fill, no pulse'); @@ -501,7 +501,7 @@ test('Hive #16268 shape: held native Fixing waits for a fixer in the CI/Review p const item = livePR({ stage: 70, modifiers: ['hold'], hold: { by: 'hanthor', reason: 'Maintainer hold' }, display_column: 50, code_activity: { head: 'head', state: 'waiting_fixer', caption: 'Waiting for fixer · no code work observed', source: 'native-fix-request' }, - ci_activity: activity('missing', 'CI waiting · required check "test" hasn\'t reported for this head yet'), + ci_activity: activity('missing', "CI waiting · required check 'test' hasn't reported for this head yet"), review_activity: activity('approved', 'Review approved'), }); const cells = physicalTracks(item); @@ -526,7 +526,7 @@ test('current phase, running activity, failure and successful completion are ind ['failing', 'CI failing · "build" red', false, 'failing'], ['running', 'CI running · 1/2 checks done', true, 'active'], ['passing', 'CI green · all 2 required checks passed', false, 'done'], - ['skipped', 'CI skipped · check "build" skipped', false, 'todo'], + ['skipped', "CI skipped · check 'build' skipped", false, 'todo'], ]) { const cells = physicalTracks(livePR({ ci_activity: activity(state, caption, running) })); assert.ok(cells.ci.includes('ham-activity-track ' + cls + ' ham-current'), state + ' → ' + cls + ': ' + cells.ci); @@ -759,30 +759,66 @@ test('linked movement uses current-head repair evidence while native sort stays }); test('the backend detail sentence rides in the track tooltip, not on the chevron', () => { - const detail = 'Branch protection requires a check named "test", but no check run or commit status with that name exists for the PR\'s current commit.'; - const item = livePR({ ci_activity: { ...activity('missing', 'CI waiting · required check "test" hasn\'t reported for this head yet'), detail } }); + const detail = "Branch protection requires a check named 'test', but no check run or commit status with that name exists for the PR's current commit."; + const item = livePR({ ci_activity: { ...activity('missing', "CI waiting · required check 'test' hasn't reported for this head yet"), detail } }); const html = track(item, 'ci', { state: 'active' }, false, now); const panel = html.match(/aria-describedby="[^"]+">([^]*?)[^]*hasn't reported for this head yet · Branch protection requires a check named "test"/); - assert.match(html, /title="[^"]*Branch protection requires a check named "test", but no check run/); + assert.match(html, /role="tooltip">Current pipeline phase · CI: CI \?\/\? · no checks reported yet · Branch protection requires a check named 'test'/); + assert.match(html, /title="[^"]*Branch protection requires a check named 'test', but no check run/); + // The detail sentence is the caption spelled out: the caption does not + // repeat beside it, and the blocker is not a third mention (#16630). + assert.doesNotMatch(html, /hasn't reported for this head yet/); + assert.equal((html.match(/role="tooltip">([^<]*?) · head /)[1].match(/test/g) || []).length, 1, 'the unreported check is named once in the tooltip'); +}); + +test('#16630: a head with checks still reporting is running, never "activity unknown", and the tooltip states each fact once', () => { + const stale = now + 10 * 60 * 1000; + const detail = '7 of the 11 required checks have a final result; the rest are still executing on the PR\'s current commit. Required check \'test\' has not reported for this head yet.'; + const item = livePR({ ci_activity: { ...activity('running', 'CI running · 4 checks pending', true), detail, checks_passed: 7, checks_total: 11, checks_pending: ['a', 'b', 'c', 'test'] } }); + const html = track(item, 'ci', { state: 'active' }, false, stale); + const tip = html.match(/role="tooltip">([^<]*)/)[1]; + assert.equal(tip, 'Current pipeline phase · CI: CI 7/11 · 4 running · ' + esc(detail) + ' · head head · observed-test-source · stale · 2026-11-02T21:00:00.000Z (10m ago) · since 2026-11-02T20:59:00.000Z · hive is waiting on CI'); + assert.doesNotMatch(html, /activity unknown|last observed running|no verdict yet|no check results observed/); + assert.match(html, /ham-activity-track active ham-current/, 'a stale poll of a counted running head keeps the lit fill'); + assert.doesNotMatch(html, /data-motion/, 'but does not pulse'); + // Row B: the required set unknown, 12/66 reported — the unfinished count, not "no verdict yet". + const rowB = livePR({ ci_activity: { ...activity('running', 'CI running · 54 checks pending', true), detail: '12 of the 66 checks observed on the head have a final result; the rest are still executing.', checks_passed: 12, checks_total: 66 } }); + const b = track(rowB, 'ci', { state: 'active' }, false, now); + assert.match(b, /ham-chevron-copy ham-track-state">CI 12\/66 · 54 running([^<]*)/)[1]; + assert.match(mt, /^Current pipeline phase · CI: CI 7\/11 · 'test' not reported · Branch protection requires a check named 'test', but no check run[^·]*·( \S+ ago ·)? head head/); + assert.doesNotMatch(mt, /activity unknown|last observed missing|CI waiting/); + assert.equal((mt.split(' · head ')[0].match(/test/g) || []).length, 2, 'count word + detail: not caption, blocker and detail again'); }); test('#16484: count grammar — CI passed/total and Review done/total across every state', () => { const word = new Function(trackConsts + '\n' + fn(strip, 'stageTrackerWorkflowApprovalPending') + fn(strip, 'stageTrackerQueueAheadWord') + fn(strip, 'stageTrackerHiveOwnsRepair') + fn(strip, 'stageTrackerWaitingOnPerson') + fn(strip, 'stageTrackerTrackRunning') + fn(strip, 'stageTrackerTrackWord') + ';return stageTrackerTrackWord;')(); const ci = (state, extra = {}) => word({ head: 'h', ci_activity: { head: 'h', state, ...extra } }, 'ci', true); assert.equal(ci('passing', { checks_passed: 14, checks_total: 14 }), 'CI 14/14 passed'); - assert.equal(ci('failing', { checks_passed: 11, checks_total: 14, checks_failed: 1, checks_failing: ['lint'] }), 'CI 11/14 · 1 failing (lint)'); - assert.equal(ci('failing', { checks_passed: 10, checks_total: 14, checks_failed: 3, checks_failing: ['lint', 'test', 'e2e'] }), 'CI 10/14 · 3 failing (lint, test, …)'); - assert.equal(ci('failing', { blocker: 'native-queue-policy' }), 'CI ?/? · failing (native-queue-policy)', 'older servers without counts still name the red check'); - assert.equal(ci('running', { checks_passed: 3, checks_total: 14 }), 'CI 3/14 · running'); - assert.equal(ci('running', { checks_passed: 3, checks_total: 14, checks_failed: 1, checks_failing: ['lint'] }), 'CI 3/14 · running · 1 failing (lint)'); - assert.equal(ci('queued', { checks_passed: 0, checks_total: 14 }), 'CI 0/14 · queued'); + assert.equal(ci('failing', { checks_passed: 11, checks_total: 14, checks_failed: 1, checks_failing: ['lint'] }), "CI 11/14 · 1 failing ('lint')"); + assert.equal(ci('failing', { checks_passed: 10, checks_total: 14, checks_failed: 3, checks_failing: ['lint', 'test', 'e2e'] }), "CI 10/14 · 3 failing ('lint', 'test', …)"); + assert.equal(ci('failing', { blocker: 'native-queue-policy' }), "CI ?/? · failing ('native-queue-policy')", 'older servers without counts still name the red check'); + assert.equal(ci('running', { checks_passed: 3, checks_total: 14 }), 'CI 3/14 · 11 running'); + assert.equal(ci('running', { checks_passed: 3, checks_total: 14, checks_failed: 1, checks_failing: ['lint'] }), "CI 3/14 · 10 running · 1 failing ('lint')"); + assert.equal(ci('running', { checks_passed: 9, checks_total: 11, checks_pending: ['check-09', 'test'] }), "CI 9/11 · 'check-09', 'test' running", 'the last one or two unfinished checks are named (#16630)'); + assert.equal(ci('running', { checks_passed: 7, checks_total: 11, checks_pending: ['a', 'b', 'c', 'test'] }), 'CI 7/11 · 4 running'); + assert.equal(ci('queued', { checks_passed: 0, checks_total: 14 }), 'CI 0/14 · 14 queued'); + assert.equal(ci('queued', { checks_passed: 13, checks_total: 14, checks_pending: ['test'] }), "CI 13/14 · 'test' queued"); assert.equal(ci('missing', { checks_passed: 0, checks_total: 14, blocker: 'test' }), 'CI 0/14 · no checks reported yet'); - assert.equal(ci('missing', { checks_passed: 13, checks_total: 14, blocker: 'test' }), 'CI 13/14 · test not reported'); - assert.equal(ci('skipped', { checks_passed: 13, checks_total: 14, blocker: 'build' }), 'CI 13/14 · build skipped'); + assert.equal(ci('missing', { checks_passed: 13, checks_total: 14, blocker: 'test' }), "CI 13/14 · 'test' not reported"); + assert.equal(ci('skipped', { checks_passed: 13, checks_total: 14, blocker: 'build' }), "CI 13/14 · 'build' skipped"); assert.equal(ci('unknown'), 'CI ?/? · no checks reported yet'); - assert.equal(ci('unknown', { checks_passed: 51, checks_total: 68 }), 'CI 51/68 · running', 'unprotected base: an unfinished head-wide ring is still running (#16631)'); + assert.equal(ci('unknown', { checks_passed: 51, checks_total: 68 }), 'CI 51/68 · 17 running', 'unprotected base: the unfinished count, never "no verdict yet" (#16630)'); + assert.equal(ci('unknown', { checks_passed: 11, checks_total: 66, checks_failed: 1, checks_failing: ['flaky'] }), "CI 11/66 · 1 failing ('flaky') · 54 running"); + assert.equal(ci('unknown', { checks_passed: 12, checks_total: 12 }), 'CI 12/12 · required set unknown'); + assert.equal(ci('unknown', { checks_passed: 2, checks_total: 3, blocker: 'test' }), "CI 2/3 · 'test' unclear"); + assert.equal(ci('unknown', { checks_passed: 3, checks_total: 3, blocker: 'commit statuses not observed' }), 'CI 3/3 · commit statuses not observed'); assert.equal(word({ head: 'h' }, 'ci', true), 'CI ?/? · no checks reported yet', 'no evidence at all in the current phase'); assert.equal(word({ head: 'h' }, 'ci', false), '', 'no evidence outside the current phase: not started, glyph alone'); assert.equal(word({ head: 'h', ci_activity: { head: 'old', state: 'passing', checks_passed: 14, checks_total: 14 } }, 'ci', true), 'CI ?/? · no checks reported yet', 'old-head evidence counts for nothing'); @@ -820,7 +856,7 @@ test('#16484: the three screenshot rows — both tracks lit with counts, swarm r let cells = physicalTracks(livePR({ head, stage: 70, display_column: 50, push: { state: 'pushed', sha: head, next: 're-review' }, code_activity: { head, state: 'pushed', caption: 'New head pushed · CI and re-review', source: 'recorded-push' }, ci_activity: fresh('running', { checks_passed: 9, checks_total: 14, active: true }), review_activity: fresh('unknown', { perspectives_done: 0, perspectives_total: 5 }) })); - assert.equal(cls(cells.ci), 'active'); assert.equal(text(cells.ci), 'CI 9/14 · running'); + assert.equal(cls(cells.ci), 'active'); assert.equal(text(cells.ci), 'CI 9/14 · 5 running'); assert.match(cells.ci, /data-motion="active"/); // #16599: the pending re-review is not in motion and not the stage's own // track (070) → glyph alone, its words in the tooltip. @@ -835,7 +871,7 @@ test('#16484: the three screenshot rows — both tracks lit with counts, swarm r // words even while only queued; CI runs beside it (two lit). assert.equal(cls(cells.review), 'active'); assert.equal(text(cells.review), 'Review 0/5 · queued'); assert.doesNotMatch(cells.review, /data-motion/, 'queued is lit but still'); - assert.equal(cls(cells.ci), 'active'); assert.equal(text(cells.ci), 'CI 2/14 · running'); + assert.equal(cls(cells.ci), 'active'); assert.equal(text(cells.ci), 'CI 2/14 · 12 running'); // #16268: CI failed native-queue-policy, review approved, held. cells = physicalTracks(livePR({ head, stage: 70, display_column: 50, modifiers: ['hold'], hold: { by: 'hanthor', pill: 'Held by @hanthor' }, ci_activity: fresh('failing', { checks_passed: 13, checks_total: 14, checks_failed: 1, checks_failing: ['native-queue-policy'], blocker: 'native-queue-policy' }), @@ -845,8 +881,8 @@ test('#16484: the three screenshot rows — both tracks lit with counts, swarm r // the settled approval is the glyph alone, its count words in the tooltip. const tip = cell => cell.match(/ aria-label="([^"]*)"/)[1]; assert.equal(cls(cells.ci), 'active'); assert.match(cells.ci, /ham-activity-track active ham-stalled/); assert.doesNotMatch(cells.ci, /data-motion/); - assert.equal(text(cells.ci), 'CI 13/14 · 1 failing (native-queue-policy)'); assert.match(cells.ci, /data-verdict="fail"/); - assert.match(tip(cells.ci), /^(?:Current pipeline phase · )?CI: CI 13\/14 · 1 failing \(native-queue-policy\) · /); + assert.equal(text(cells.ci), "CI 13/14 · 1 failing ('native-queue-policy')"); assert.match(cells.ci, /data-verdict="fail"/); + assert.match(tip(cells.ci), /^(?:Current pipeline phase · )?CI: CI 13\/14 · 1 failing \('native-queue-policy'\) · /); assert.equal(cls(cells.review), 'done'); assert.equal(text(cells.review), ''); assert.match(cells.review, /data-verdict="pass"/); assert.match(tip(cells.review), /^(?:Current pipeline phase · )?Review: Review 5\/5 approved · /); assert.match(cells.review, /Held by @hanthor/); @@ -879,7 +915,7 @@ test('#16615: CI green on the pushed head + re-review owed by the hive → Revie 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.ci), 'active'); assert.equal(text(running.ci), 'CI 7/11 · 4 running'); assert.equal(cls(running.review), 'todo'); assert.equal(text(running.review), ''); }); diff --git a/src/pkg/dashboard/stage_tracker_activity_test.go b/src/pkg/dashboard/stage_tracker_activity_test.go index 154611699e..f2cf9e9de7 100644 --- a/src/pkg/dashboard/stage_tracker_activity_test.go +++ b/src/pkg/dashboard/stage_tracker_activity_test.go @@ -363,12 +363,12 @@ func TestStageTrackerActivityCICaptionsReadInPlainLanguage(t *testing.T) { state, want string detailMention string }{ - {"missing", ci(done("build"), done("lint")), "missing", `CI waiting · required check "test" hasn't reported for this head yet`, `check named "test"`}, - {"running counts", ci(done("build"), chk("lint", "in_progress", ""), chk("test", "in_progress", "")), "running", "CI running · 1/3 checks done", "1 of the 3 required checks"}, - {"queued", ci(done("build"), done("lint"), chk("test", "queued", "")), "queued", `CI queued · "test" waiting for a runner`, "not started"}, - {"failing", ci(done("build"), chk("lint", "completed", "failure"), done("test")), "failing", `CI failing · "lint" red`, `"lint" finished without success`}, - {"skipped", ci(done("build"), done("lint"), chk("test", "completed", "skipped")), "skipped", `CI skipped · check "test" skipped`, "does not count as a pass"}, - {"ambiguous", ci(done("build"), done("lint"), done("test"), chk("test", "completed", "failure")), "unknown", `CI unknown · "test" reported but with no conclusion`, "several runs share the name"}, + {"missing", ci(done("build"), done("lint")), "missing", `CI waiting · required check 'test' hasn't reported for this head yet`, `check named 'test'`}, + {"running counts", ci(done("build"), chk("lint", "in_progress", ""), chk("test", "in_progress", "")), "running", `CI running · 'lint', 'test' pending`, "1 of the 3 required checks"}, + {"queued", ci(done("build"), done("lint"), chk("test", "queued", "")), "queued", `CI queued · 'test' waiting for a runner`, "not started"}, + {"failing", ci(done("build"), chk("lint", "completed", "failure"), done("test")), "failing", `CI failing · 'lint' red`, `'lint' finished without success`}, + {"skipped", ci(done("build"), done("lint"), chk("test", "completed", "skipped")), "skipped", `CI skipped · check 'test' skipped`, "does not count as a pass"}, + {"ambiguous", ci(done("build"), done("lint"), done("test"), chk("test", "completed", "failure")), "unknown", `CI unknown · 'test' reported but with no conclusion`, "several runs share the name"}, {"green", ci(done("build"), done("lint"), done("test")), "passing", "CI green · all 3 required checks passed", "reported success"}, } for _, tc := range cases { @@ -384,8 +384,8 @@ func TestStageTrackerActivityCICaptionsReadInPlainLanguage(t *testing.T) { pr github.PullRequest want string }{ - {"red+running", ci(done("build"), chk("lint", "completed", "failure"), chk("test", "in_progress", "")), "CI running · 2/3 checks done · 1 failing"}, - {"missing+running", ci(done("build"), chk("lint", "in_progress", "")), "CI running · 1/3 checks done"}, + {"red+running", ci(done("build"), chk("lint", "completed", "failure"), chk("test", "in_progress", "")), `CI running · 'test' pending · 1 failing`}, + {"missing+running", ci(done("build"), chk("lint", "in_progress", "")), `CI running · 'lint', 'test' pending`}, } for _, tc := range motion { got := stageTrackerCIActivity(tc.pr, now) @@ -393,7 +393,7 @@ func TestStageTrackerActivityCICaptionsReadInPlainLanguage(t *testing.T) { t.Fatalf("%s: want running %q active, got %+v", tc.name, tc.want, got) } } - if got := stageTrackerCIActivity(ci(done("build"), done("lint"), done("lint"), chk("test", "queued", "")), now); got.State != "queued" || got.Caption != `CI queued · "test" waiting for a runner` { + if got := stageTrackerCIActivity(ci(done("build"), done("lint"), done("lint"), chk("test", "queued", "")), now); got.State != "queued" || got.Caption != `CI queued · 'test' waiting for a runner` { t.Fatalf("ambiguous+queued: a waiting runner keeps the ring queued, not unknown: %+v", got) } if got := stageTrackerCIActivity(ci(done("build"), chk("lint", "completed", "failure"), done("test")), now); got.State != "failing" || got.Active { @@ -538,7 +538,7 @@ func TestStageTrackerActivityCIPartialRingIsRunning(t *testing.T) { Required: required, RequiredSource: "protection", RequiredChecks: bindings, Checks: checks}} } got := stageTrackerCIActivity(build(13, 6), now) - if got.State != "running" || !got.Active || got.ChecksPassed != 13 || got.ChecksTotal != 19 || got.Caption != "CI running · 13/19 checks done" { + if got.State != "running" || !got.Active || got.ChecksPassed != 13 || got.ChecksTotal != 19 || got.Caption != "CI running · 6 checks pending" { t.Fatalf("13/19 with 6 pending must be an active running track: %+v", got) } full := stageTrackerCIActivity(build(19, 0), now) @@ -548,7 +548,126 @@ func TestStageTrackerActivityCIPartialRingIsRunning(t *testing.T) { // Required set unknown: the head-wide count still reads motion. loose := build(13, 6) loose.CIActivity.RequiredKnown, loose.CIActivity.Required, loose.CIActivity.RequiredChecks = false, nil, nil - if got := stageTrackerCIActivity(loose, now); got.State != "running" || !got.Active || got.Caption != "CI running · 13/16 checks done" { + if got := stageTrackerCIActivity(loose, now); got.State != "running" || !got.Active || got.Caption != "CI running · 3 checks pending" { t.Fatalf("head-wide count with checks in progress must run: %+v", got) } } + +// hivecommons/hive#16630: a head with checks still reporting is running, +// never "activity unknown" or "no check results observed"; the unreported +// required check is one sentence in Detail, and "no verdict yet" / "no +// check results observed" are reserved for a head with zero check runs. +func TestStageTrackerActivityCIRunningWhileChecksPending(t *testing.T) { + now := time.Date(2026, 11, 4, 12, 0, 0, 0, time.UTC) + t1, t2, t3 := now.Add(-9*time.Minute), now.Add(-6*time.Minute), now.Add(-3*time.Minute) + name := func(i int) string { return fmt.Sprintf("check-%02d", i) } + run := func(n string, state, conclusion string, at *time.Time) github.PRActivityCheck { + return github.PRActivityCheck{Name: n, State: state, Conclusion: conclusion, Since: at} + } + // Row A: 11 required checks, 7 green, 3 in progress, "test" has no run yet. + rowA := func() github.PullRequest { + var required []github.PRRequiredCheck + var names []string + var checks []github.PRActivityCheck + for i := 0; i < 7; i++ { + required, names = append(required, github.PRRequiredCheck{Name: name(i), AppKnown: true}), append(names, name(i)) + checks = append(checks, run(name(i), "completed", "success", &t1)) + } + for i := 7; i < 10; i++ { + required, names = append(required, github.PRRequiredCheck{Name: name(i), AppKnown: true}), append(names, name(i)) + checks = append(checks, run(name(i), "in_progress", "", &t3)) + } + required, names = append(required, github.PRRequiredCheck{Name: "test", AppKnown: true}), append(names, "test") + return github.PullRequest{HeadSHA: "head", CIActivity: &github.PRCIActivity{Head: "head", Source: "github-check-runs", ObservedAt: &t2, StatusesKnown: true, + RequiredKnown: true, Required: names, RequiredSource: "protection", RequiredChecks: required, Checks: checks}} + } + // Row B: required set unknown, 66 check runs observed, 12 green, 54 running. + rowB := func() github.PullRequest { + var checks []github.PRActivityCheck + for i := 0; i < 12; i++ { + checks = append(checks, run(name(i), "completed", "success", &t1)) + } + for i := 12; i < 66; i++ { + checks = append(checks, run(name(i), "in_progress", "", &t3)) + } + return github.PullRequest{HeadSHA: "head", CIActivity: &github.PRCIActivity{Head: "head", Source: "github-check-runs", ObservedAt: &t2, Checks: checks}} + } + twoLeft := rowA() + twoLeft.CIActivity.Checks = twoLeft.CIActivity.Checks[:7] + twoLeft.CIActivity.Checks = append(twoLeft.CIActivity.Checks, run(name(7), "completed", "success", &t2), run(name(8), "completed", "success", &t2), run(name(9), "in_progress", "", &t3)) + queuedOnly := rowA() + for i := 7; i < 10; i++ { + queuedOnly.CIActivity.Checks[i].State = "queued" + } + settledMissing := rowA() + settledMissing.CIActivity.Checks = settledMissing.CIActivity.Checks[:7] + empty := rowB() + empty.CIActivity.Checks = nil + cases := []struct { + name string + pr github.PullRequest + state, caption string + passed, total int + pending int + since *time.Time + detailHas string + detailLacks string + blocker string + captionForbidden []string + }{ + {"row A required: 7/11 with 3 running and test unreported", rowA(), "running", "CI running · 4 checks pending", 7, 11, 4, &t3, + `Required check 'test' has not reported for this head yet.`, "Branch protection requires", "", []string{"unknown", "waiting", "not reported"}}, + {"row A with two left names them", twoLeft, "running", `CI running · 'check-09', 'test' pending`, 9, 11, 2, &t3, + `'test' has not reported`, "", "", []string{"unknown"}}, + {"row A with only queued runs is queued, not missing", queuedOnly, "queued", "CI queued · 4 checks pending", 7, 11, 4, &t3, + `'test' has not reported`, "", "", []string{"unknown", "waiting"}}, + {"row A with every run final keeps the missing verdict", settledMissing, "missing", `CI waiting · required check 'test' hasn't reported for this head yet`, 7, 11, 4, nil, + `check named 'test'`, "", "test", nil}, + {"row B head-wide: 12/66 with 54 running", rowB(), "running", "CI running · 54 checks pending", 12, 66, 54, &t3, + "12 of the 66 checks observed on the head have a final result", "no check results observed", "", []string{"unknown", "no verdict", "no check results"}}, + {"row B with zero runs is the only unknown", empty, "unknown", stageTrackerCINoDataCaption("head"), 0, 0, 0, nil, + "has not yet seen", "", "", nil}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + got := stageTrackerCIActivity(tc.pr, now) + if got.State != tc.state || got.Caption != tc.caption { + t.Fatalf("state/caption = %s %q, want %s %q (%+v)", got.State, got.Caption, tc.state, tc.caption, got) + } + if got.ChecksPassed != tc.passed || got.ChecksTotal != tc.total || len(got.ChecksPending) != tc.pending || got.ChecksFailed != 0 { + t.Fatalf("counts = %d/%d pending %v failed %d, want %d/%d pending %d", got.ChecksPassed, got.ChecksTotal, got.ChecksPending, got.ChecksFailed, tc.passed, tc.total, tc.pending) + } + if !strings.Contains(got.Detail, tc.detailHas) || (tc.detailLacks != "" && strings.Contains(got.Detail, tc.detailLacks)) { + t.Fatalf("detail = %q, want mention of %q and none of %q", got.Detail, tc.detailHas, tc.detailLacks) + } + if strings.Count(got.Detail, "test") > 1 && tc.state != "missing" { + t.Fatalf("detail repeats the unreported check: %q", got.Detail) + } + if got.Blocker != tc.blocker { + t.Fatalf("blocker = %q, want %q", got.Blocker, tc.blocker) + } + if (tc.since == nil) != (got.Since == nil) || (tc.since != nil && !got.Since.Equal(*tc.since)) { + t.Fatalf("since = %v, want %v (latest check-run timestamp on the head)", got.Since, tc.since) + } + for _, word := range tc.captionForbidden { + if strings.Contains(strings.ToLower(got.Caption), word) { + t.Fatalf("caption %q must not say %q while checks are pending", got.Caption, word) + } + } + }) + } + // Row B with a red check and runs still pending: motion leads the red + // neighbour (hivecommons/hive#16631); the caption carries both. + red := rowB() + red.CIActivity.Checks[0] = run(name(0), "completed", "failure", &t1) + if got := stageTrackerCIActivity(red, now); got.State != "running" || got.Caption != "CI running · 54 checks pending · 1 failing" || got.ChecksFailed != 1 || got.Blocker != "" { + t.Fatalf("red head-wide: %+v", got) + } + // Running is active whatever the poll's age, in the head-wide path too + // (hivecommons/hive#16643): the observation time rides the tooltip. + for _, pr := range []github.PullRequest{rowB(), func() github.PullRequest { fresh := rowB(); fresh.CIActivity.ObservedAt = &now; return fresh }()} { + if got := stageTrackerCIActivity(pr, now); !got.Active { + t.Fatalf("running head-wide should be active: %+v", got) + } + } +} diff --git a/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js b/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js index 0be376687b..ff2ffec02d 100644 --- a/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js +++ b/src/pkg/dashboard/stage_tracker_remediation_chevron.test.js @@ -161,27 +161,27 @@ const seen = '2026-11-04T02:44:00Z'; test('#16509 row: adopted, CI 7/11 unreported, review 5/5 decided → one amber chevron', () => { const item = redPR({ stage: 74, display_column: 30, code_activity: { head: 'abc1234def', state: 'adopted', caption: 'Adopted by hive · activity', source: 'adoption', observed_at: seen }, - ci_activity: { head: 'abc1234def', state: 'missing', caption: 'CI waiting · required check "test" hasn\'t reported for this head yet', checks_passed: 7, checks_total: 11, blocker: 'test', source: 'checks', observed_at: seen }, + ci_activity: { head: 'abc1234def', state: 'missing', caption: "CI waiting · required check 'test' hasn't reported for this head yet", checks_passed: 7, checks_total: 11, blocker: 'test', source: 'checks', observed_at: seen }, review_activity: { head: 'abc1234def', state: 'human_decision', caption: 'Review findings · human decision', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen } }); const c = cells(item); assert.match(c[3], /class="ham-seg active detoured"/, 'the stage chevron is the one lit chevron'); // #16599: unreported checks are not motion and not the stage's track → // neutral glyph alone, count words in the tooltip. assert.match(c[4], /class="ham-seg ham-activity-track todo"/, 'unreported checks are not motion'); - assert.match(c[4], /title="CI: CI 7\/11 · test not reported · /); - assert.doesNotMatch(c[4], /test not reported { const owner = { head: 'abc1234def', state: 'waiting_owner', caption: 'Waiting for @hanthor · not observed coding', actor: 'hanthor', source: 'native-author-wait', observed_at: seen }; - const ci = { head: 'abc1234def', state: 'missing', caption: 'CI waiting · required check "test" hasn\'t reported for this head yet', checks_passed: 7, checks_total: 11, blocker: 'test', source: 'checks', observed_at: seen }; + const ci = { head: 'abc1234def', state: 'missing', caption: "CI waiting · required check 'test' hasn't reported for this head yet", checks_passed: 7, checks_total: 11, blocker: 'test', source: 'checks', observed_at: seen }; const approved = { head: 'abc1234def', state: 'approved', caption: 'Review approved', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen }; const c = cells(redPR({ stage: 71, display_column: 30, author: 'hanthor', author_kind: 'human', code_activity: owner, ci_activity: ci, review_activity: approved })); assert.match(c[3], /class="ham-seg active detoured"/); - assert.match(c[4], /class="ham-seg ham-activity-track todo"[^>]*title="CI: CI 7\/11 · test not reported · /); - assert.doesNotMatch(c[4], /test not reported]*title="CI: CI 7\/11 · 'test' not reported · /); + assert.doesNotMatch(c[4], /'test' not reported<\/span>/); assert.equal(litCount(c.join('')), 1); // Even a queued check does not light CI while the row waits on a person. @@ -220,16 +220,16 @@ test('three qualify: CI and review running on a lit PR in progress → tracks wi test('#16634 shape: CI 4/11 · 1 failing still running + unassigned → CI is the one active chevron, PR in progress icon only', () => { const base = { display_column: 30, code_activity: { head: 'abc1234def', state: 'unassigned', caption: 'Unassigned · next: scanner', source: 'no-pickup-evidence', since: seen, observed_at: seen }, - ci_activity: { head: 'abc1234def', state: 'running', active: true, caption: 'CI running · 4/11 checks done · 1 failing', checks_passed: 4, checks_total: 11, checks_failed: 1, checks_failing: ['Sign-off survives'], source: 'checks', observed_at: seen }, + ci_activity: { head: 'abc1234def', state: 'running', active: true, caption: 'CI running · 6 checks pending · 1 failing', checks_passed: 4, checks_total: 11, checks_failed: 1, checks_failing: ['Sign-off survives'], source: 'checks', observed_at: seen }, review_activity: { head: 'abc1234def', state: 'changes_requested', caption: 'Review 5/5 · changes requested', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen } }; const a = cells(redPR(base)); - assert.match(a[4], /class="ham-seg ham-activity-track active"[^]*CI 4\/11 · [^<]*1 failing \(Sign-off survives\)([^]*?)<\/span>/.exec(li); const words = m ? m[2].replace(/<[^>]+>/g, '').trim() : ''; diff --git a/src/pkg/dashboard/stage_tracker_ui_rows_test.go b/src/pkg/dashboard/stage_tracker_ui_rows_test.go index c14baba62b..18d5ebb399 100644 --- a/src/pkg/dashboard/stage_tracker_ui_rows_test.go +++ b/src/pkg/dashboard/stage_tracker_ui_rows_test.go @@ -706,19 +706,19 @@ assert.ok(/[^<]*<\/span>/.test(row) && !/ // settled-current. The ≤2 invariant itself runs on every fixture above. { const seen = new Date(now - 60000).toISOString(); - const unreported = { head: 'f269349', state: 'missing', caption: 'CI waiting · required check "test" hasn\'t reported for this head yet', checks_passed: 7, checks_total: 11, blocker: 'test', source: 'checks', observed_at: seen }; + const unreported = { head: 'f269349', state: 'missing', caption: "CI waiting · required check 'test' hasn't reported for this head yet", checks_passed: 7, checks_total: 11, blocker: 'test', source: 'checks', observed_at: seen }; const lit = (html) => litChevrons(strip(html)); const three = stageTrackerRowHtml({ repo: 'acme/console', number: 16509, kind: 'pr', stage: 74, display_column: 30, head: 'f269349', author: 'thatguywob', author_kind: 'human', code_activity: { head: 'f269349', state: 'adopted', caption: 'Adopted by hive · activity', source: 'adoption', observed_at: seen }, ci_activity: unreported, 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.strictEqual(lit(three), 1, 'adopted + unreported CI + decided review lights one chevron: ' + strip(three)); - assert.ok(/
  • ]*title="CI: CI 7\/11 · test not reported · /.test(three), 'unreported checks are the neutral icon, words in the tooltip: ' + three); + assert.ok(/
  • ]*title="CI: CI 7\/11 · 'test' not reported · /.test(three), 'unreported checks are the neutral icon, words in the tooltip: ' + three); const owner = stageTrackerRowHtml({ repo: 'acme/console', number: 16268, kind: 'pr', stage: 71, display_column: 30, head: 'f269349', author: 'hanthor', author_kind: 'human', code_activity: { head: 'f269349', state: 'waiting_owner', caption: 'Waiting for @hanthor · not observed coding', actor: 'hanthor', source: 'native-author-wait', observed_at: seen }, ci_activity: unreported, review_activity: { head: 'f269349', state: 'approved', caption: 'Review approved', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen } }, stages, ctx); assert.strictEqual(lit(owner), 1, 'with the contributor: only the stage chevron is lit: ' + strip(owner)); assert.ok(/
  • ]*aria-current="step"/.test(owner) && owner.includes('Waiting for @hanthor'), owner); - assert.ok(/
  • ]*title="CI: CI 7\/11 · test not reported · /.test(owner) && /
  • ]*data-verdict="pass"[^>]*>[\s\S]*?ham-track-verdict">]*>[\s\S]*?<\/svg><\/span>[\s\S]*?Review: Review 5\/5 approved · /.test(owner), 'with the contributor both tracks are icons alone, words in the tooltips: ' + owner); + assert.ok(/
  • ]*title="CI: CI 7\/11 · 'test' not reported · /.test(owner) && /
  • ]*data-verdict="pass"[^>]*>[\s\S]*?ham-track-verdict">]*>[\s\S]*?<\/svg><\/span>[\s\S]*?Review: Review 5\/5 approved · /.test(owner), 'with the contributor both tracks are icons alone, words in the tooltips: ' + owner); const busy = stageTrackerRowHtml({ repo: 'acme/console', number: 16456, kind: 'pr', stage: 70, display_column: 30, head: 'f269349', author: 'hive[bot]', author_kind: 'hive', code_activity: { head: 'f269349', state: 'remediating', caption: 'Remediating · scanner · 4m', actor: 'scanner', active: true, source: 'fix-dispatch', observed_at: seen }, ci_activity: { head: 'f269349', state: 'running', active: true, caption: 'CI running', checks_passed: 4, checks_total: 11, source: 'checks', observed_at: seen }, @@ -806,13 +806,13 @@ assert.ok(/[^<]*<\/span>/.test(row) && !/ review_activity: { head: '9bdf058', state: 'reviewing', active: true, caption: 'Review 2/5 · in progress', perspectives_done: 2, perspectives_total: 5, source: 'verified-review-bundle+stage-review-pending', observed_at: seen } }, stages, ctx); assert.strictEqual(lit(progress), 1, 'review in progress lights the Review column only: ' + strip(progress)); assert.ok(/
  • ]*data-motion="active"[^>]*>[\s\S]*?Review 2\/5 · in progress<\/span>/.test(progress), progress); - assert.ok(/
  • ]*>[\s\S]*?]*data-ring-done="7"[\s\S]*?<\/svg><\/span>]*>[\s\S]*?]*data-ring-done="7"[\s\S]*?<\/svg><\/span>]*data-ring-total="5" data-ring-done="2"/.test(progress) && (progress.match(/ham-ring-pulse/g) || []).length === 1, 'the review ring pulses its next step: ' + progress); const both = stageTrackerRowHtml({ repo: 'acme/promptargs', number: 427, kind: 'pr', stage: 50, display_column: 50, head: '9bdf058', author: 'hive[bot]', author_kind: 'hive', ci_activity: { head: '9bdf058', state: 'running', active: true, caption: 'CI running', checks_passed: 4, checks_total: 11, source: 'checks', observed_at: seen }, review_activity: { head: '9bdf058', state: 'adjudicating', active: true, caption: 'Review 5/5 · verdicts in · aggregating', perspectives_done: 5, perspectives_total: 5, source: 'verified-review-bundle', observed_at: seen } }, stages, ctx); assert.strictEqual(lit(both), 2, 'CI running + adjudicating: both tracks, no third: ' + strip(both)); - assert.ok(both.includes('CI 4/11 · running') && both.includes('Review 5/5 · adjudicating'), both); + assert.ok(both.includes('CI 4/11 · 7 running') && both.includes('Review 5/5 · adjudicating'), both); } // Merged: the lit cap is the only chevron with hover text. row = stageTrackerRowHtml({ repo: 'acme/console', number: 106, kind: 'pr', stage: 110 }, stages, ctx); 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 d3daf54cb8..631f1bba1d 100644 --- a/src/pkg/dashboard/static-src/js/tracker-row-strip.js +++ b/src/pkg/dashboard/static-src/js/tracker-row-strip.js @@ -65,21 +65,36 @@ const failed = n('checks_failed'); const names = matches && Array.isArray(a.checks_failing) ? a.checks_failing : []; const count = 'CI ' + (total ? passed + '/' + total : '?/?'); - const failing = failed ? failed + ' failing' + (names.length ? ' (' + names.slice(0, 2).join(', ') + (names.length > 2 ? ', …' : '') + ')' : '') : ''; + // A check name inside the words wears single quotes ('test' not + // reported) so it stands apart from the words around it. + const q = n => "'" + n + "'"; + const failing = failed ? failed + ' failing' + (names.length ? ' (' + names.slice(0, 2).map(q).join(', ') + (names.length > 2 ? ', …' : '') + ')' : '') : ''; const blocker = matches && a.blocker ? String(a.blocker) : ''; + // The unfinished count carries information; "no verdict yet" or a + // bare "running" beside 12/66 did not (hivecommons/hive#16630). The + // last one or two unfinished names are spelled out. + const pendingNames = matches && Array.isArray(a.checks_pending) ? a.checks_pending.map(String).filter(Boolean) : []; + const pendingCount = total ? Math.max(total - passed - failed, pendingNames.length) : pendingNames.length; + const pending = verb => !pendingCount ? verb : pendingNames.length && pendingNames.length <= STAGE_TRACKER_PENDING_CHECKS_NAMED ? pendingNames.map(q).join(', ') + ' ' + verb : pendingCount + ' ' + verb; switch (state) { case 'passing': return count + ' passed'; - case 'failing': return count + ' · ' + (failing || 'failing' + (blocker ? ' (' + blocker + ')' : '')); - case 'running': return count + ' · running' + (failing ? ' · ' + failing : ''); - case 'queued': return count + ' · queued' + (failing ? ' · ' + failing : ''); - case 'skipped': return count + ' · ' + (blocker ? blocker + ' skipped' : 'skipped'); + case 'failing': return count + ' · ' + (failing || 'failing' + (blocker ? ' (' + q(blocker) + ')' : '')); + case 'running': return count + ' · ' + pending('running') + (failing ? ' · ' + failing : ''); + case 'queued': return count + ' · ' + pending('queued') + (failing ? ' · ' + failing : ''); + case 'skipped': return count + ' · ' + (blocker ? q(blocker) + ' skipped' : 'skipped'); case 'missing': { if (stageTrackerWorkflowApprovalPending(a) > 0) return count + ' · waiting on workflow approval' + (failing ? ' · ' + failing : ''); - return count + ' · ' + (passed ? (blocker ? blocker + ' not reported' : 'not all reported') : 'no checks reported yet') + (failing ? ' · ' + failing : ''); + return count + ' · ' + (passed ? (blocker ? q(blocker) + ' not reported' : 'not all reported') : 'no checks reported yet') + (failing ? ' · ' + failing : ''); + } + default: { + if (!total) return count + ' · no checks reported yet'; + if (failing) return count + ' · ' + failing + (pendingCount ? ' · ' + pending('running') : ''); + // A blocker here is a phrase ("commit statuses not observed") or + // the one check whose result cannot be read. + if (blocker) return count + ' · ' + (/\s/.test(blocker) ? blocker : q(blocker) + ' unclear'); + if (pendingCount) return count + ' · ' + pending('running'); + return count + ' · required set unknown'; } - // An unfinished ring with no settled word is still running - // (hivecommons/hive#16631). - default: return count + ' · ' + (total ? (passed + failed < total ? 'running' + (failing ? ' · ' + failing : '') : 'no verdict yet') : 'no checks reported yet'); } } const total = n('perspectives_total'); @@ -126,6 +141,9 @@ // person's click moves them, so the chevron names the wait and wears // the person icon (hivecommons/hive#16599). const STAGE_TRACKER_WORKFLOW_APPROVAL_BLOCKER = 'workflow-approval-required:'; + // Up to this many unfinished check names are spelled out in the CI + // chevron word; beyond it the count speaks (hivecommons/hive#16630). + const STAGE_TRACKER_PENDING_CHECKS_NAMED = 2; const STAGE_TRACKER_WORKFLOW_APPROVAL_TIP = 'Needs a maintainer to approve the workflow runs on GitHub before the checks can start'; function stageTrackerWorkflowApprovalPending(a) { if (!a) return 0; @@ -317,17 +335,25 @@ const source = matches ? a.source || 'unavailable' : 'unavailable'; const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale · ' : 'observed · ') + new Date(observed).toISOString() + ' (' + stageTrackerAgoWord(observed, clock) + ')'; const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' · since ' + new Date(a.since).toISOString() : ''; - 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 : ''; + const detail = matches && a.detail ? String(a.detail) : ''; const sinceAgo = matches && a.since && Number.isFinite(Date.parse(a.since)) && settledState ? ' · ' + stageTrackerAgoWord(Date.parse(a.since), clock) : ''; - let tip = caption + blocker + detail + sinceAgo + (perspectives.length ? ' · ' + perspectives.map(perspectiveLine).join(' · ') : '') + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; + // Each fact once (hivecommons/hive#16630): the count word, then the + // caption unless the detail sentence already spells it out, then the + // blocker and the ask unless an earlier fact already names them. + const facts = []; + const say = fact => { if (fact && !facts.some(f => f.toLowerCase().includes(fact.toLowerCase()))) facts.push(fact); }; + say(text); + if (!(text && detail)) say(caption); + say(detail); + if (matches && a.blocker) say(String(a.blocker)); + say(ask); + let tip = facts.join(' · ') + sinceAgo + (perspectives.length ? ' · ' + perspectives.map(perspectiveLine).join(' · ') : '') + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; const code = item.code_activity; const codeNote = code && code.head === item.head && Number(item.display_column) === 50 && ((kind === 'review' && code.state === 'waiting_fixer') || (kind === 'ci' && code.state === 'waiting_ci')) ? code.caption : ''; @@ -356,7 +382,7 @@ const evidenceLink = ownsPR && evidenceURL ? `${icon}${word}` : icon + word; const routeState = (sg.state || 'todo') + (sg.detour ? ' detoured' : ''); const hold = item.hold; - const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + (text && text !== caption ? text + ' · ' : '') + tip + + const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + tip + (matches && a.actor ? ' · actor ' + a.actor : '') + (codeNote || contextWord ? ' · ' + (codeNote || contextWord) : '') + (hold ? ' · ' + (hold.pill || 'Held by @' + hold.by) + (hold.reason ? ' · ' + hold.reason : '') : '') + diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index f3aa9ca177..0c8a192069 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -18001,21 +18001,36 @@

    Where to get help

    const failed = n('checks_failed'); const names = matches && Array.isArray(a.checks_failing) ? a.checks_failing : []; const count = 'CI ' + (total ? passed + '/' + total : '?/?'); - const failing = failed ? failed + ' failing' + (names.length ? ' (' + names.slice(0, 2).join(', ') + (names.length > 2 ? ', …' : '') + ')' : '') : ''; + // A check name inside the words wears single quotes ('test' not + // reported) so it stands apart from the words around it. + const q = n => "'" + n + "'"; + const failing = failed ? failed + ' failing' + (names.length ? ' (' + names.slice(0, 2).map(q).join(', ') + (names.length > 2 ? ', …' : '') + ')' : '') : ''; const blocker = matches && a.blocker ? String(a.blocker) : ''; + // The unfinished count carries information; "no verdict yet" or a + // bare "running" beside 12/66 did not (hivecommons/hive#16630). The + // last one or two unfinished names are spelled out. + const pendingNames = matches && Array.isArray(a.checks_pending) ? a.checks_pending.map(String).filter(Boolean) : []; + const pendingCount = total ? Math.max(total - passed - failed, pendingNames.length) : pendingNames.length; + const pending = verb => !pendingCount ? verb : pendingNames.length && pendingNames.length <= STAGE_TRACKER_PENDING_CHECKS_NAMED ? pendingNames.map(q).join(', ') + ' ' + verb : pendingCount + ' ' + verb; switch (state) { case 'passing': return count + ' passed'; - case 'failing': return count + ' · ' + (failing || 'failing' + (blocker ? ' (' + blocker + ')' : '')); - case 'running': return count + ' · running' + (failing ? ' · ' + failing : ''); - case 'queued': return count + ' · queued' + (failing ? ' · ' + failing : ''); - case 'skipped': return count + ' · ' + (blocker ? blocker + ' skipped' : 'skipped'); + case 'failing': return count + ' · ' + (failing || 'failing' + (blocker ? ' (' + q(blocker) + ')' : '')); + case 'running': return count + ' · ' + pending('running') + (failing ? ' · ' + failing : ''); + case 'queued': return count + ' · ' + pending('queued') + (failing ? ' · ' + failing : ''); + case 'skipped': return count + ' · ' + (blocker ? q(blocker) + ' skipped' : 'skipped'); case 'missing': { if (stageTrackerWorkflowApprovalPending(a) > 0) return count + ' · waiting on workflow approval' + (failing ? ' · ' + failing : ''); - return count + ' · ' + (passed ? (blocker ? blocker + ' not reported' : 'not all reported') : 'no checks reported yet') + (failing ? ' · ' + failing : ''); + return count + ' · ' + (passed ? (blocker ? q(blocker) + ' not reported' : 'not all reported') : 'no checks reported yet') + (failing ? ' · ' + failing : ''); + } + default: { + if (!total) return count + ' · no checks reported yet'; + if (failing) return count + ' · ' + failing + (pendingCount ? ' · ' + pending('running') : ''); + // A blocker here is a phrase ("commit statuses not observed") or + // the one check whose result cannot be read. + if (blocker) return count + ' · ' + (/\s/.test(blocker) ? blocker : q(blocker) + ' unclear'); + if (pendingCount) return count + ' · ' + pending('running'); + return count + ' · required set unknown'; } - // An unfinished ring with no settled word is still running - // (hivecommons/hive#16631). - default: return count + ' · ' + (total ? (passed + failed < total ? 'running' + (failing ? ' · ' + failing : '') : 'no verdict yet') : 'no checks reported yet'); } } const total = n('perspectives_total'); @@ -18062,6 +18077,9 @@

    Where to get help

    // person's click moves them, so the chevron names the wait and wears // the person icon (hivecommons/hive#16599). const STAGE_TRACKER_WORKFLOW_APPROVAL_BLOCKER = 'workflow-approval-required:'; + // Up to this many unfinished check names are spelled out in the CI + // chevron word; beyond it the count speaks (hivecommons/hive#16630). + const STAGE_TRACKER_PENDING_CHECKS_NAMED = 2; const STAGE_TRACKER_WORKFLOW_APPROVAL_TIP = 'Needs a maintainer to approve the workflow runs on GitHub before the checks can start'; function stageTrackerWorkflowApprovalPending(a) { if (!a) return 0; @@ -18253,17 +18271,25 @@

    Where to get help

    const source = matches ? a.source || 'unavailable' : 'unavailable'; const freshness = !Number.isFinite(observed) ? 'observation time unknown' : (stale ? 'stale · ' : 'observed · ') + new Date(observed).toISOString() + ' (' + stageTrackerAgoWord(observed, clock) + ')'; const since = matches && a.since && Number.isFinite(Date.parse(a.since)) ? ' · since ' + new Date(a.since).toISOString() : ''; - 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 : ''; + const detail = matches && a.detail ? String(a.detail) : ''; const sinceAgo = matches && a.since && Number.isFinite(Date.parse(a.since)) && settledState ? ' · ' + stageTrackerAgoWord(Date.parse(a.since), clock) : ''; - let tip = caption + blocker + detail + sinceAgo + (perspectives.length ? ' · ' + perspectives.map(perspectiveLine).join(' · ') : '') + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; + // Each fact once (hivecommons/hive#16630): the count word, then the + // caption unless the detail sentence already spells it out, then the + // blocker and the ask unless an earlier fact already names them. + const facts = []; + const say = fact => { if (fact && !facts.some(f => f.toLowerCase().includes(fact.toLowerCase()))) facts.push(fact); }; + say(text); + if (!(text && detail)) say(caption); + say(detail); + if (matches && a.blocker) say(String(a.blocker)); + say(ask); + let tip = facts.join(' · ') + sinceAgo + (perspectives.length ? ' · ' + perspectives.map(perspectiveLine).join(' · ') : '') + ' · head ' + (item.head || 'unknown') + ' · ' + source + ' · ' + freshness + since; const code = item.code_activity; const codeNote = code && code.head === item.head && Number(item.display_column) === 50 && ((kind === 'review' && code.state === 'waiting_fixer') || (kind === 'ci' && code.state === 'waiting_ci')) ? code.caption : ''; @@ -18292,7 +18318,7 @@

    Where to get help

    const evidenceLink = ownsPR && evidenceURL ? `${icon}${word}` : icon + word; const routeState = (sg.state || 'todo') + (sg.detour ? ' detoured' : ''); const hold = item.hold; - const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + (text && text !== caption ? text + ' · ' : '') + tip + + const fullTip = (current ? 'Current pipeline phase · ' : '') + name + ': ' + tip + (matches && a.actor ? ' · actor ' + a.actor : '') + (codeNote || contextWord ? ' · ' + (codeNote || contextWord) : '') + (hold ? ' · ' + (hold.pill || 'Held by @' + hold.by) + (hold.reason ? ' · ' + hold.reason : '') : '') + From 859b7df40a784a374a1e6368c4bcbb8e875199c3 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 22:38:30 +0000 Subject: [PATCH 20/24] =?UTF-8?q?=F0=9F=93=96=20docs(api-reference):=20lis?= =?UTF-8?q?t=20check-count=20and=20perspective=20fields=20on=20activity=20?= =?UTF-8?q?observations=20(#16672)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #16670 Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-16670-api-reference-activity-fields.md | 1 + src/docs/api-reference/dashboard-misc.md | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 changelog.d/fixed-16670-api-reference-activity-fields.md diff --git a/changelog.d/fixed-16670-api-reference-activity-fields.md b/changelog.d/fixed-16670-api-reference-activity-fields.md new file mode 100644 index 0000000000..7064d76189 --- /dev/null +++ b/changelog.d/fixed-16670-api-reference-activity-fields.md @@ -0,0 +1 @@ +- API reference now lists the check-count and perspective fields of stage-tracker activity observations ([#16670](https://github.com/hivecommons/hive/issues/16670)). diff --git a/src/docs/api-reference/dashboard-misc.md b/src/docs/api-reference/dashboard-misc.md index 1eb2f14639..0ae5ac24e2 100644 --- a/src/docs/api-reference/dashboard-misc.md +++ b/src/docs/api-reference/dashboard-misc.md @@ -5,13 +5,17 @@ Part of the [Dashboard REST API reference](../api-reference.md); see that page f `GET /api/stage-tracker` adds independent PR `ci_activity`, `review_activity` and `code_activity` observations, also copied to `linked_prs[]`. Each is -`{head, state, caption, actor?, source, observed_at?, since?, blocker?, url?, active?}`. +`{head, state, caption, detail?, actor?, source, observed_at?, since?, blocker?, url?, active?, checks_passed?, checks_total?, checks_failed?, checks_failing?, checks_pending?, perspectives_done?, perspectives_total?, perspectives?}`. These are display evidence, **not merge authorization**. An absent timestamp means unknown freshness; a different head invalidates the observation. -CI is classified only against the resolved required set from the existing -check snapshot. Review assignment comes from dispatch, current work additionally -requires its actual worker, and approval/findings require verified current-head -review evidence. Authors and claimants are not inferred reviewers. +`detail?` is the longer, plain-language sentence behind caption. `checks_failing?` +and `checks_pending?` are string lists of check names; `perspectives?` list +per-perspective verdicts on the head. CI is classified against the resolved +required set when branch protection is known, otherwise against every check run +observed on the head (checks_total == 0 means no count could be made). Review +assignment comes from dispatch, current work additionally requires its actual +worker, and approval/findings require verified current-head review evidence. +Authors and claimants are not inferred reviewers. `display_column` may be `30` (source repair or explicit owner/adoption wait) or `50` (CI and re-review), without changing native stage identities, counts, filters or routing. Consumers must not turn either display field into a gate. From 04e5ca04a3625cbde2b304bc453d8918150d6c63 Mon Sep 17 00:00:00 2001 From: thatguywob Date: Wed, 4 Nov 2026 17:04:30 -0700 Subject: [PATCH 21/24] =?UTF-8?q?=F0=9F=93=96=20docs:=20align=20StageTrack?= =?UTF-8?q?erActivity=20CI=20provenance=20comment=20(#16674)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 📖 docs: align StageTrackerActivity CI provenance comment Describe the resolved required-check set and the observed head-wide fallback consistently with the field comment and dashboard API docs. Hive-Run: hivecommons/hive#16673 Hive-Plan: stage-tracker-activity-comment-alignment Hive-Spec: hivecommons/hive#16673#type-comment Signed-off-by: thatguywob * 📖 docs: add changelog fragment for CI provenance clarification Signed-off-by: thatguywob --------- Signed-off-by: thatguywob Co-authored-by: thatguywob --- changelog.d/fixed-16674-stage-tracker-ci-comment.md | 1 + src/pkg/dashboard/stage_tracker_activity.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-16674-stage-tracker-ci-comment.md diff --git a/changelog.d/fixed-16674-stage-tracker-ci-comment.md b/changelog.d/fixed-16674-stage-tracker-ci-comment.md new file mode 100644 index 0000000000..125add8378 --- /dev/null +++ b/changelog.d/fixed-16674-stage-tracker-ci-comment.md @@ -0,0 +1 @@ +- Clarify the `StageTrackerActivity` source documentation: CI activity uses the resolved required checks when branch protection is known, otherwise all check runs observed on the head. This corrects the description without changing runtime behavior ([#16674](https://github.com/hivecommons/hive/pull/16674)). diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index dcefe29406..98a7be52a0 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -15,7 +15,8 @@ import ( // StageTrackerActivity keeps independent observations separate from the lane's // native stage and next mover. Worker activity requires assignment AND worker; -// CI activity comes only from observed required checks. +// CI activity uses the resolved required set when branch protection is known, +// otherwise every check run observed on the head. type StageTrackerActivity struct { Head string `json:"head"` State string `json:"state"` From f358b7308eab4d0b6e2d3b39a611e9e818429cbf Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Thu, 5 Nov 2026 00:15:49 +0000 Subject: [PATCH 22/24] =?UTF-8?q?=F0=9F=8C=B1=20test(crux):=20pin=20that?= =?UTF-8?q?=20a=20bad=20OTEL=20config=20disables=20telemetry,=20not=20the?= =?UTF-8?q?=20command=20(#16671)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * test(crux): pin that a bad OTEL config disables telemetry, not the command cmd/crux and crux/cmd/crux both promise (hivecommons/crux#19) that a rejected OTEL_EXPORTER_OTLP_* configuration prints a 'telemetry disabled' notice and lets the verb run; neither main_test.go exercised that branch, so cmd/crux sat at 77.8% with the fallback as one of its two uncovered statements. Both tests now drive run() with an unsupported protocol and assert the notice, the variable name and the verb's own exit code. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> * ci: retrigger after runner toolchain download failure The coverage job failed because the runner could not download go 1.26.10 and was left with a trimmed go binary (no GOROOT). No code change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- src/cmd/crux/main_test.go | 18 ++++++++++++++++++ src/crux/cmd/crux/main_test.go | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/src/cmd/crux/main_test.go b/src/cmd/crux/main_test.go index bb7fe83c62..69b61ae46d 100644 --- a/src/cmd/crux/main_test.go +++ b/src/cmd/crux/main_test.go @@ -44,3 +44,21 @@ func TestRunReportsVersion(t *testing.T) { t.Fatalf("code %d, stdout %q", code, stdout.String()) } } + +// A bad OTEL configuration costs telemetry, never the command +// (hivecommons/crux#19): run reports the refusal on stderr and the verb still +// completes with its own exit code. +func TestRunKeepsCommandWhenTelemetryConfigIsBad(t *testing.T) { + t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://127.0.0.1:1") + t.Setenv("OTEL_EXPORTER_OTLP_PROTOCOL", "grpc") + var stdout, stderr bytes.Buffer + code := run([]string{"--version"}, strings.NewReader(""), &stdout, &stderr, func() (context.Context, context.CancelFunc) { + return context.WithCancel(context.Background()) + }) + if code != cli.ExitOK || stdout.String() != "crux "+cli.DefaultVersion+"\n" { + t.Fatalf("code %d, stdout %q, stderr %q", code, stdout.String(), stderr.String()) + } + if !strings.Contains(stderr.String(), "crux: telemetry disabled:") || !strings.Contains(stderr.String(), "OTEL_EXPORTER_OTLP_PROTOCOL") { + t.Fatalf("stderr = %q, want the telemetry-disabled notice naming the bad variable", stderr.String()) + } +} diff --git a/src/crux/cmd/crux/main_test.go b/src/crux/cmd/crux/main_test.go index 709a3ee79b..0ec75b7c97 100644 --- a/src/crux/cmd/crux/main_test.go +++ b/src/crux/cmd/crux/main_test.go @@ -50,6 +50,22 @@ func TestRunReportsVersion(t *testing.T) { } } +// A bad OTEL configuration costs telemetry, never the command +// (hivecommons/crux#19): run reports the refusal on stderr and the verb still +// completes with its own exit code. +func TestRunKeepsCommandWhenTelemetryConfigIsBad(t *testing.T) { + t.Setenv("OTEL_EXPORTER_OTLP_ENDPOINT", "http://127.0.0.1:1") + t.Setenv("OTEL_EXPORTER_OTLP_PROTOCOL", "grpc") + var stdout, stderr bytes.Buffer + code := run([]string{"--version"}, strings.NewReader(""), &stdout, &stderr, testCtx) + if code != cli.ExitOK || stdout.String() != "crux "+cli.DefaultVersion+"\n" { + t.Fatalf("code %d, stdout %q, stderr %q", code, stdout.String(), stderr.String()) + } + if !strings.Contains(stderr.String(), "crux: telemetry disabled:") || !strings.Contains(stderr.String(), "OTEL_EXPORTER_OTLP_PROTOCOL") { + t.Fatalf("stderr = %q, want the telemetry-disabled notice naming the bad variable", stderr.String()) + } +} + func TestRunPSFromDefsDirectory(t *testing.T) { dir := t.TempDir() defsDir := filepath.Join(dir, "defs") From dcc92db2fb765b2a7e783875a4a2e29dd7b17a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ra=C3=BAl=20M=C3=A9ndez?= <18744521+mendezr@users.noreply.github.com> Date: Thu, 5 Nov 2026 01:24:58 +0100 Subject: [PATCH 23/24] =?UTF-8?q?=F0=9F=90=9B=20fix(ci):=20retry=20transie?= =?UTF-8?q?nt=20Cline=20dependency=20installs=20(#16667)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Implement issue option B in both images: four attempts with 60-second pauses and metadata revalidation. Preserve install errors on exhaustion and only link and smoke-test after success. Exercise the shipped RUN bodies with mocked tools through the existing supply-chain CI step. Hive-Run: hivecommons/hive#16666 Hive-Plan: issue-16666-option-B-bounded-retry Hive-Spec: issue-16666#option-B Signed-off-by: mendezr Co-authored-by: mendezr Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-cline-install-retry.md | 1 + src/Dockerfile | 11 ++- src/Dockerfile.contributor | 11 ++- src/deploy/test_cline_install_retry.py | 90 ++++++++++++++++++++++++ src/deploy/test_supply_chain_pins.sh | 8 +++ 5 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixed-cline-install-retry.md create mode 100644 src/deploy/test_cline_install_retry.py diff --git a/changelog.d/fixed-cline-install-retry.md b/changelog.d/fixed-cline-install-retry.md new file mode 100644 index 0000000000..934efb0933 --- /dev/null +++ b/changelog.d/fixed-cline-install-retry.md @@ -0,0 +1 @@ +- Hive and contributor image builds retry Cline installation with fresh npm metadata up to four times to tolerate transient registry propagation failures ([#16666](https://github.com/hivecommons/hive/issues/16666)). diff --git a/src/Dockerfile b/src/Dockerfile index d72d97e141..0ae1bf25eb 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -318,7 +318,16 @@ RUN timeout 120s npm install -g --ignore-scripts --no-fund --no-audit \ # static list, and non-codex backends are unaffected. ARG CODEX_VERSION=0.166.0 ARG CLINE_VERSION=3.0.74 -RUN npm install -g --ignore-scripts --no-fund --no-audit cline@${CLINE_VERSION} \ +# npm can briefly advertise AWS SDK versions before all registry replicas serve +# them. Wait at most three minutes between attempts and revalidate metadata. +RUN attempt=1; \ + until npm install -g --ignore-scripts --no-fund --no-audit --prefer-online cline@${CLINE_VERSION}; do \ + status=$?; \ + if [ "$attempt" -ge 4 ]; then exit "$status"; fi; \ + echo "Cline install failed (attempt $attempt/4); retrying in 60s" >&2; \ + sleep 60; \ + attempt=$((attempt + 1)); \ + done \ && ln -sf "$(npm root -g)/cline/bin/cline" /usr/local/bin/cline \ && cline --version RUN npm install -g --ignore-scripts --no-fund --no-audit @openai/codex@${CODEX_VERSION} && npm cache clean --force || \ diff --git a/src/Dockerfile.contributor b/src/Dockerfile.contributor index 34f1a0ea5c..22d91ca230 100644 --- a/src/Dockerfile.contributor +++ b/src/Dockerfile.contributor @@ -551,7 +551,16 @@ COPY bin/hive-config.sh /usr/local/bin/ # proactive quota protection with no custom reader and no local hive server. COPY --from=quota-publisher-builder /hive-quota-publisher /usr/local/bin/hive-quota-publisher COPY --from=quota-publisher-builder /crux /usr/local/bin/crux -RUN npm install -g --ignore-scripts --no-fund --no-audit cline@${CLINE_VERSION} \ +# npm can briefly advertise AWS SDK versions before all registry replicas serve +# them. Wait at most three minutes between attempts and revalidate metadata. +RUN attempt=1; \ + until npm install -g --ignore-scripts --no-fund --no-audit --prefer-online cline@${CLINE_VERSION}; do \ + status=$?; \ + if [ "$attempt" -ge 4 ]; then exit "$status"; fi; \ + echo "Cline install failed (attempt $attempt/4); retrying in 60s" >&2; \ + sleep 60; \ + attempt=$((attempt + 1)); \ + done \ && ln -sf "$(npm root -g)/cline/bin/cline" /usr/local/bin/cline \ && cline --version COPY config/backends.conf /usr/local/etc/hive/ diff --git a/src/deploy/test_cline_install_retry.py b/src/deploy/test_cline_install_retry.py new file mode 100644 index 0000000000..bb05f66242 --- /dev/null +++ b/src/deploy/test_cline_install_retry.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python3 +"""Exercise the shipped Cline RUN commands without npm, network, or Docker.""" + +import os +from pathlib import Path +import re +import subprocess +import tempfile +import unittest + + +SRC = Path(__file__).resolve().parents[1] +MOCKS = r''' +count=0 +npm() { + if [ "$1" = root ]; then echo /mock/node_modules; return 0; fi + printf 'npm %s\n' "$*" >> "$CALL_LOG" + count=$((count + 1)) + if [ "$count" -le "$FAILURES" ]; then + echo 'npm error code ETARGET: No matching version found' >&2 + return 42 + fi +} +sleep() { echo "sleep $*" >> "$CALL_LOG"; } +ln() { echo "ln $*" >> "$CALL_LOG"; } +cline() { echo "cline $*" >> "$CALL_LOG"; return "$VERSION_STATUS"; } +''' + + +class ClineInstallRetryTest(unittest.TestCase): + def run_install(self, dockerfile, failures, version_status=0): + # Join Docker continuations, then run the actual RUN body under /bin/sh + # just like the images. No copied retry implementation in this test. + text = (SRC / dockerfile).read_text().replace("\\\n", " ") + commands = [ + line.removeprefix("RUN ") + for line in text.splitlines() + if line.startswith("RUN ") + and re.search(r"npm install .*cline@", line) + ] + self.assertEqual(len(commands), 1, dockerfile) + with tempfile.TemporaryDirectory() as directory: + log = Path(directory) / "calls" + log.touch() + result = subprocess.run( + ["/bin/sh", "-c", MOCKS + commands[0]], + env={**os.environ, "CALL_LOG": str(log), + "FAILURES": str(failures), "CLINE_VERSION": "3.0.74", + "VERSION_STATUS": str(version_status)}, + capture_output=True, text=True, timeout=5, + ) + calls = log.read_text().splitlines() + return result, calls + + def test_install_retry_and_failure(self): + for dockerfile in ("Dockerfile", "Dockerfile.contributor"): + # Includes success on the final allowed attempt and exhaustion. + for failures in (0, 1, 3, 4): + with self.subTest(dockerfile=dockerfile, failures=failures): + result, calls = self.run_install(dockerfile, failures) + self.assertEqual(result.returncode, 42 if failures == 4 else 0, + result.stderr) + installs = [call for call in calls if call.startswith("npm ")] + self.assertEqual(len(installs), min(failures + 1, 4)) + for install in installs: + self.assertEqual(install.split(), [ + "npm", "install", "-g", "--ignore-scripts", "--no-fund", + "--no-audit", "--prefer-online", "cline@3.0.74", + ]) + self.assertEqual(calls.count("sleep 60"), min(failures, 3)) + self.assertEqual([call for call in calls if call.startswith("sleep ")], + ["sleep 60"] * min(failures, 3)) + post_install = [call for call in calls + if call.startswith(("ln ", "cline "))] + self.assertEqual(post_install, [] if failures == 4 else [ + "ln -sf /mock/node_modules/cline/bin/cline /usr/local/bin/cline", + "cline --version", + ]) + + def test_version_failure_is_not_retried_or_masked(self): + for dockerfile in ("Dockerfile", "Dockerfile.contributor"): + with self.subTest(dockerfile=dockerfile): + result, calls = self.run_install(dockerfile, 0, version_status=17) + self.assertEqual(result.returncode, 17, result.stderr) + self.assertEqual(sum(call.startswith("npm ") for call in calls), 1) + self.assertFalse(any(call.startswith("sleep ") for call in calls)) + + +if __name__ == "__main__": + unittest.main() diff --git a/src/deploy/test_supply_chain_pins.sh b/src/deploy/test_supply_chain_pins.sh index 499510bf10..c1ddb2ec53 100755 --- a/src/deploy/test_supply_chain_pins.sh +++ b/src/deploy/test_supply_chain_pins.sh @@ -221,6 +221,14 @@ else "expected a 'git -C /opt/nous checkout \"\${NOUS_COMMIT}\"' step in $DOCKERFILE" fi +# Execute the real Cline install RUN bodies with mocked npm/links/sleep. This +# keeps the bounded retry covered by the existing supply-chain CI step. +if python3 "$V2_DIR/deploy/test_cline_install_retry.py"; then + pass "Cline installs tolerate transient registry failures and fail closed" +else + fail "Cline install retry behavior" +fi + echo echo "=== $PASS passed, $FAIL failed ===" [ "$FAIL" -eq 0 ] || exit 1 From 856537726e0b15749d2f6c283810a245568ffda0 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Wed, 4 Nov 2026 19:40:14 -0500 Subject: [PATCH 24/24] =?UTF-8?q?=F0=9F=90=9B=20review:=20superseding=20PR?= =?UTF-8?q?=20with=20unanimous=20sign-off=20requires=5Fhuman=20parks=20for?= =?UTF-8?q?=20a=20decision,=20not=20the=20fixer=20(#16676)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A hive-superseding PR whose every reviewer perspective returned requires_human as a pure approver question (decision requested, no finding above info) was routed to the fixer by the superseder rule. The fixer had nothing to push, the cycle hit its cap, fixer-exhausted re-authored the change, and the next PR repeated it (#16398 -> #16456 -> #16607) while no operator was ever asked. Aggregation now keeps such a head requires_human with its decision question, RouteHuman parks it at 085 needs-decision with approve / request-changes actions, and the tracker's review chevron says the head is verified and waiting on sign-off. Fixes #16675 Signed-off-by: Andrew Anderson Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-superseder-signoff-park.md | 1 + src/pkg/dashboard/stage_tracker_activity.go | 19 +++++ .../dashboard/stage_tracker_activity_test.go | 20 +++++ src/pkg/review/hive_superseding_test.go | 83 ++++++++++++++++++- src/pkg/review/review.go | 39 ++++++++- src/pkg/stagelabels/hive_superseder_test.go | 20 +++++ src/pkg/stagelabels/human.go | 9 +- 7 files changed, 184 insertions(+), 7 deletions(-) create mode 100644 changelog.d/fixed-superseder-signoff-park.md diff --git a/changelog.d/fixed-superseder-signoff-park.md b/changelog.d/fixed-superseder-signoff-park.md new file mode 100644 index 0000000000..90c1ab9a5b --- /dev/null +++ b/changelog.d/fixed-superseder-signoff-park.md @@ -0,0 +1 @@ +- Review aggregation no longer routes a hive-superseding PR to the fixer when every perspective's `requires_human` is a pure approver question with nothing above an informational finding. That route dispatched no-op fix kicks until the cycle was exhausted, then re-authored the same change (#16398 → #16456 → #16607) while the approver the reviewer asked never saw a decision. Such a head keeps its decision question, parks at `stage/085-needs-decision` with approve / request-changes actions, and the tracker's review chevron reads "waiting on a human approver · reviewer verified, needs sign-off". diff --git a/src/pkg/dashboard/stage_tracker_activity.go b/src/pkg/dashboard/stage_tracker_activity.go index 98a7be52a0..1a89343b02 100644 --- a/src/pkg/dashboard/stage_tracker_activity.go +++ b/src/pkg/dashboard/stage_tracker_activity.go @@ -701,6 +701,9 @@ func stageTrackerReviewActivity(pr github.PullRequest, bundle *evidence.Bundle, out.Blocker = stageTrackerFixerExhaustedSummary(agg) case "requires_human": out.State, out.Caption = "human_decision", "Review findings · needs owner sign-off" + if trackerAggregateSignOffOnly(*agg) { + out.Caption = "Waiting on a human approver · reviewer verified, needs sign-off" + } out.Blocker = agg.DecisionQuestion } } @@ -909,3 +912,19 @@ func stageTrackerApplyCodeActivity(it *StageTrackerItem, dispatch review.Dispatc } } } + +// trackerAggregateSignOffOnly reports a requires_human aggregate whose +// perspectives asked an approver a question and none found code to change: +// the review verified the head and only a person's sign-off is owed +// (hivecommons/hive#16607). +func trackerAggregateSignOffOnly(agg review.Aggregate) bool { + if !agg.DecisionRequested || strings.TrimSpace(agg.DecisionQuestion) == "" { + return false + } + for _, v := range agg.Perspectives { + if v == review.VerdictChangesRequested || v == review.VerdictReject { + return false + } + } + return true +} diff --git a/src/pkg/dashboard/stage_tracker_activity_test.go b/src/pkg/dashboard/stage_tracker_activity_test.go index f2cf9e9de7..56f729e835 100644 --- a/src/pkg/dashboard/stage_tracker_activity_test.go +++ b/src/pkg/dashboard/stage_tracker_activity_test.go @@ -671,3 +671,23 @@ func TestStageTrackerActivityCIRunningWhileChecksPending(t *testing.T) { } } } + +// A requires_human aggregate whose perspectives only asked an approver a +// question (no changes_requested) is a verified head waiting on sign-off, +// not "findings" (hivecommons/hive#16607); one requesting changes is not. +func TestTrackerAggregateSignOffOnly(t *testing.T) { + signOff := review.Aggregate{Verdict: review.VerdictRequiresHuman, DecisionRequested: true, DecisionQuestion: "@owner confirm?", + Perspectives: map[review.Perspective]review.Verdict{review.PerspectiveSecurity: review.VerdictRequiresHuman, review.PerspectiveStyle: review.VerdictRequiresHuman}} + if !trackerAggregateSignOffOnly(signOff) { + t.Fatalf("sign-off aggregate not recognised: %+v", signOff) + } + withFix := signOff + withFix.Perspectives = map[review.Perspective]review.Verdict{review.PerspectiveSecurity: review.VerdictRequiresHuman, review.PerspectiveCorrectness: review.VerdictChangesRequested} + noQuestion := signOff + noQuestion.DecisionRequested, noQuestion.DecisionQuestion = false, "" + for name, agg := range map[string]review.Aggregate{"changes requested sibling": withFix, "no question": noQuestion} { + if trackerAggregateSignOffOnly(agg) { + t.Errorf("%s: wrongly recognised as sign-off only", name) + } + } +} diff --git a/src/pkg/review/hive_superseding_test.go b/src/pkg/review/hive_superseding_test.go index 13bd8d76d9..dc7068d4ae 100644 --- a/src/pkg/review/hive_superseding_test.go +++ b/src/pkg/review/hive_superseding_test.go @@ -3,12 +3,17 @@ package review import ( "strings" "testing" + + "github.com/hivecommons/hive/pkg/outputschema" ) // hiveSupersederSecurityReport is a security-sensitive requires_human on a -// PR the hive created to supersede another PR. +// PR the hive created to supersede another PR, with a finding the fixer +// can act on. func hiveSupersederSecurityReport() PerspectiveReport { - r := baseReport(PerspectiveSecurity, VerdictRequiresHuman) + r := baseReport(PerspectiveSecurity, VerdictRequiresHuman, outputschema.Finding{ + Title: "token logged at debug level", Severity: outputschema.SeverityMedium, File: "auth.go", Line: 12, + }) r.HiveAuthored = true r.HiveSuperseding = true r.DecisionRequested = true @@ -16,6 +21,80 @@ func hiveSupersederSecurityReport() PerspectiveReport { return r } +// hiveSupersederSignOffReport is the hivecommons/hive#16607 shape: every +// perspective requires_human, each only asking an approver to confirm a +// trust-boundary change, with at most an informational finding. +func hiveSupersederSignOffReport(p Perspective) PerspectiveReport { + r := baseReport(p, VerdictRequiresHuman) + r.HiveAuthored = true + r.HiveSuperseding = true + r.DecisionRequested = true + r.DecisionRiskHigh = true + r.DecisionQuestion = "@hanthor should confirm that the relay may now App-merge trusted-author pin-only PRs." + if p == PerspectiveSecurity { + r.Findings = []outputschema.Finding{{ + Title: "relay now lifts the human-merge-path hold", Severity: outputschema.SeverityInfo, + Summary: "Needs approver sign-off, not a code fix.", File: "src/pkg/github/human_merge_paths.go", Line: 269, + }} + } + return r +} + +// TestAggregateHiveSupersedingSignOffOnlyParksForDecision: when every +// perspective's requires_human is a pure approver question with nothing +// above an informational finding, the superseder rule has no fix to route. +// The aggregate keeps the decision request so the stage engine parks the PR +// at 085 needs-decision instead of kicking a fixer that has nothing to fix +// until the cycle is exhausted and the PR is re-authored (#16398 → #16456 +// → #16607). +func TestAggregateHiveSupersedingSignOffOnlyParksForDecision(t *testing.T) { + reports := []PerspectiveReport{ + hiveSupersederSignOffReport(PerspectiveCorrectness), + hiveSupersederSignOffReport(PerspectiveSecurity), + hiveSupersederSignOffReport(PerspectiveStyle), + } + got := AggregateReports(reports, AggregateOptions{}) + + if got.Verdict != VerdictRequiresHuman || !got.RequiresHuman || got.FixCycle || got.MergeEligible { + t.Fatalf("aggregate = %+v, want requires_human park", got) + } + if !got.DecisionRequested || got.DecisionQuestion == "" { + t.Fatalf("aggregate = %+v, want the decision question preserved", got) + } + if hasReason(got.Reasons, HiveSupersedingFixRouteReason) { + t.Fatalf("reasons = %v, must not carry the fix-route reason", got.Reasons) + } + for p, v := range got.Perspectives { + if v != VerdictRequiresHuman { + t.Fatalf("perspective %s = %s, want requires_human kept", p, v) + } + } + if got.Normalize().Verdict != VerdictRequiresHuman { + t.Fatalf("Normalize() = %+v, must not re-route a decision request to the fixer", got.Normalize()) + } +} + +// TestAggregateHiveSupersedingSignOffWithActionableFindingRoutesToFixer: +// a sibling perspective that found code to change keeps the owner's fixer +// route; the sign-off park is only for a swarm with nothing to fix. +func TestAggregateHiveSupersedingSignOffWithActionableFindingRoutesToFixer(t *testing.T) { + for name, extra := range map[string]PerspectiveReport{ + "changes_requested sibling": func() PerspectiveReport { + r := baseReport(PerspectiveCorrectness, VerdictChangesRequested) + r.HiveAuthored, r.HiveSuperseding = true, true + return r + }(), + "requires_human with medium finding": hiveSupersederSecurityReport(), + } { + t.Run(name, func(t *testing.T) { + got := AggregateReports([]PerspectiveReport{hiveSupersederSignOffReport(PerspectiveStyle), extra}, AggregateOptions{}) + if got.Verdict != VerdictChangesRequested || !got.FixCycle || got.DecisionRequested { + t.Fatalf("aggregate = %+v, want changes_requested fixer route", got) + } + }) + } +} + // TestAggregateHiveSupersedingRiskRequiresHumanRoutesToFixer: the owner's // rule — a security/risk requires_human on the hive's superseding PR is a // fix request, not an 085 park. diff --git a/src/pkg/review/review.go b/src/pkg/review/review.go index c3bad61c2a..132c15a406 100644 --- a/src/pkg/review/review.go +++ b/src/pkg/review/review.go @@ -454,6 +454,7 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg var decisionQuestions []string var hasReject, hasChanges, unresolvedRequiresHuman, riskEscalation bool var selfAuthoredHumanWithConcreteRemediation, selfAuthoredHumanWithoutRemediation bool + var signOffAsk, requiresHumanBeyondSignOff bool for i, r := range reports { effective := effectiveReports[i] if agg.Repo == "" { @@ -490,6 +491,11 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg case VerdictChangesRequested: hasChanges = true case VerdictRequiresHuman: + if reportAsksForSignOff(r) { + signOffAsk = true + } else { + requiresHumanBeyondSignOff = true + } if selfAuthoredRequiresHumanReportIsResolvable(r, opts) { if reportHasConcreteRemediation(r) { selfAuthoredHumanWithConcreteRemediation = true @@ -530,7 +536,8 @@ func aggregateReports(reports []PerspectiveReport, opts AggregateOptions) Aggreg sortReasons(agg.Reasons) sort.Strings(agg.HumanSummaries) - if hiveSupersedingFixRoute(agg, opts, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman) { + signOffOnly := signOffAsk && !requiresHumanBeyondSignOff && !hasReject && !hasChanges + if hiveSupersedingFixRoute(agg, opts, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman, signOffOnly) { // Owner rule: a PR the hive created to supersede another PR auto- // merges with no operator decision. A reviewer's requires_human — // a risk-class question, a security-sensitive finding — is a @@ -945,8 +952,17 @@ const HiveSupersedingFixRouteReason = "hive-authored superseding PR: reviewer re // reject stays a reject: it is an emergent problem with the PR, not a // finding to fix. Everything the self-authored path already resolves on // its own (non-risk questions, concrete remediation) keeps that path. -func hiveSupersedingFixRoute(agg Aggregate, opts AggregateOptions, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman bool) bool { - if !agg.HiveSuperseding || !agg.HiveAuthored || opts.HiveSupersedingAutoMergeOff || hasReject { +// +// signOffOnly is the one requires_human the fixer cannot answer: every +// perspective explicitly deferred a maintainer decision and none raised a +// finding above informational severity (reportAsksForSignOff). Routing that +// to the fixer dispatched six no-op fix kicks, exhausted the cycle, and +// re-authored the same change three times (#16398 → #16456 → #16607) while +// the approver who was asked never saw a decision pill. It stays a +// decision-requested requires_human, which the stage engine parks at 085 +// needs-decision with approve / request-changes options. +func hiveSupersedingFixRoute(agg Aggregate, opts AggregateOptions, hasReject, decisionRequested, riskEscalation, unresolvedRequiresHuman, signOffOnly bool) bool { + if !agg.HiveSuperseding || !agg.HiveAuthored || opts.HiveSupersedingAutoMergeOff || hasReject || signOffOnly { return false } if strings.EqualFold(strings.TrimSpace(opts.SelfAuthoredDecisionPolicy), "escalate") { @@ -955,6 +971,23 @@ func hiveSupersedingFixRoute(agg Aggregate, opts AggregateOptions, hasReject, de return unresolvedRequiresHuman || (decisionRequested && riskEscalation) } +// reportAsksForSignOff reports whether a requires_human report (the caller +// has already established the effective verdict) is a pure approver +// question: it explicitly requested a maintainer decision and carries no +// in-scope finding above informational severity, so there is no code change +// an agent could make to clear it. +func reportAsksForSignOff(r PerspectiveReport) bool { + if !r.DecisionRequested { + return false + } + for _, f := range r.Findings { + if InScopeFinding(f) && severityRank(f.Severity) > severityRank(outputschema.SeverityInfo) { + return false + } + } + return true +} + func reportsHiveSuperseding(reports []PerspectiveReport) bool { for _, r := range reports { if r.HiveSuperseding { diff --git a/src/pkg/stagelabels/hive_superseder_test.go b/src/pkg/stagelabels/hive_superseder_test.go index d71717f9e2..7f46dc11bb 100644 --- a/src/pkg/stagelabels/hive_superseder_test.go +++ b/src/pkg/stagelabels/hive_superseder_test.go @@ -81,3 +81,23 @@ func TestHiveSupersederHardStopReasonRejectsOtherReasons(t *testing.T) { t.Fatal("unknown token must have no prose") } } + +// TestRouteHumanHiveSupersederSignOffQuestionParksAt085: a requires_human +// that still carries its decision question is the aggregate's pure +// approver sign-off (nothing for the fixer, hivecommons/hive#16607). It is +// a decision with approve / request-changes actions, not a 070 row nobody +// is working. +func TestRouteHumanHiveSupersederSignOffQuestionParksAt085(t *testing.T) { + e := hiveSupersederEvidence() + e.DecisionQuestion = "@hanthor should confirm the relay may App-merge trusted pin-only PRs." + r := RouteHuman(e) + if r.Stage != NeedsDecision || r.LaneReason == LaneReasonHiveSupersederFix { + t.Fatalf("route = %+v, want 085 decision", r) + } + if !strings.Contains(strings.Join(r.Reasons, "\n"), "reviewer question: "+e.DecisionQuestion) { + t.Fatalf("reasons = %v, want the reviewer question", r.Reasons) + } + if DecisionActions(r) == "" { + t.Fatalf("route = %+v, want approve / request-changes actions", r) + } +} diff --git a/src/pkg/stagelabels/human.go b/src/pkg/stagelabels/human.go index 2a53c28a4f..1f44ebeb59 100644 --- a/src/pkg/stagelabels/human.go +++ b/src/pkg/stagelabels/human.go @@ -428,11 +428,16 @@ func RouteHuman(e Evidence) Route { } return Route{Stage: NeedsDecision, Reasons: reasons, LaneReason: LaneReasonHiveSupersederHardStopPrefix + token, Summary: summary, Head: e.Head, SelfAuthored: e.SelfAuthored, Verdict: e.Verdict, HumanApprover: strings.TrimSpace(e.HumanApprover), Hold: e.Hold} } - if e.Verdict == VerdictRequiresHuman && strings.TrimSpace(e.HumanApprover) == "" { + if e.Verdict == VerdictRequiresHuman && strings.TrimSpace(e.HumanApprover) == "" && strings.TrimSpace(e.DecisionQuestion) == "" { // Owner rule: the reviewer's finding — security-sensitive // included — is the fixer's to address, not a person's to rule // on. The aggregate routes it as changes_requested; the stage - // says so rather than "needs your decision". + // says so rather than "needs your decision". A verdict that + // still carries its decision question is the one case the + // aggregate left for a person (a pure approver sign-off with + // nothing to fix, hivecommons/hive#16607): no fixer is + // dispatched for it, so captioning it "goes to the fixer" + // parked it on 070 with nobody on it; it falls through to 085. note(HiveSupersederAutoMergeCaption+": the reviewer's finding @"+ShortSHA(e.Head)+" goes to the fixer", LaneReasonHiveSupersederFix) } }