Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/fixed-merge-gate-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Activity Monitor: a merge outcome ("Merging", "Merge failed", "Waiting for CI") always renders in the Merge gate column, whatever stage the lane fell back to; the merge-failed chip is a fixed short phrase (GitHub's refusal translated to plain words β€” "4 required checks haven't finished", "branch protection blocks it", "needs rebase", "not allowed" β€” with the raw text only in the tooltip's Details line, clamped by CSS), "retrying" while the sweep is on it; pending CI reads "CI running", never "CI is red"; cues say "back to Reviewed" instead of a stage slug; and the automerge sweep remembers GitHub's "required status checks are expected" refusal per head so it stops re-PUTting /merge every pass while the PR is still blocked (hivecommons/docs#512).
5 changes: 4 additions & 1 deletion src/docs/dashboard-sections.md
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,10 @@ Every PR at the gate now carries `merge_gate: {state, reason, sweep_running, las
| any of the above while a pass is evaluating this PR | the stage's word | *merge sweep running* | ⟳ (static) β€” *hive's merge sweep is running on this PR now.* |
| 100 merge queue | **Merging** | β€” | ⟳ (static) β€” *Admitted and soaked; hive is merging it now (GitHub merge queue / merge window).* |
| any stage while hive's merge call is in flight (`merge_gate.merging_since`, `merge_path`) | **Merging** | *merge call in flight*, then *merge landed* while the SPA holds the row | ⟳ (static) β€” *hive is merging it now (automerge sweep) β€” the merge call has been in flight since 3s ago.* |
| any stage after GitHub refused hive's merge call (`merge_gate.state: merge-failed`, `merge_failed`, `merge_failed_at`) | **Merge failed** | the refusal's first line β€” *405 Pull Request is not mergeable* | πŸ•“ clock β€” *hive tried to merge this (maintainer merge from the dashboard) 9s ago and GitHub refused: …. The lane re-evaluates it on its next pass.* |
| any stage after GitHub refused hive's merge call (`merge_gate.state: merge-failed`, `merge_failed`, `merge_failed_kind`, `merge_failed_text`, `merge_failed_at`) | **Merge failed** | the refusal translated to a short phrase β€” *branch protection*, *needs rebase*, *not allowed*, *review required*, or *retrying* while the sweep is on it; never GitHub's raw text | πŸ•“ clock β€” *hive tried to merge this (maintainer merge from the dashboard) 9s ago and GitHub refused β€” branch protection blocks it. The lane re-evaluates it on its next pass. Details: 405 Pull Request is not mergeable* |
| any stage after the merge call drew *N of M required status checks are expected* (`merge_failed_kind: checks-pending`, `merge_failed_checks`) | **Waiting for CI** | *4 checks* | ⟳ while the sweep is on it, else πŸ•“ β€” *hive tried to merge this (automerge sweep) 1m ago before its required checks had reported β€” 4 required checks haven't finished. It merges once they pass.* |

A merge outcome (**Merging**, **Merge failed**, **Waiting for CI**) always lights the **Merge gate** column, whatever numeric stage the lane fell back to (hivecommons/docs#512 drew "Merge failed" in CI / Review because the PR sat at 060).
| 110 | **Merged** (the βœ“ cap) | β€” | β€” |

#### Merging is held for the toast's lifetime
Expand Down
12 changes: 7 additions & 5 deletions src/pkg/dashboard/stage_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -1319,8 +1319,13 @@ func humanizeStageReason(reason string) string {
return "no verified claim links this PR to an issue"
case "contributor-lane:claim-tier-untrusted":
return "author's claim tier is below the auto-merge tiers"
case "ci-red", "check-runs":
return "CI is red"
case "ci-red":
return "CI failed"
case "check-runs", "status-check":
return "CI checks could not be read"
}
if words, ok := stageTrackerCIStateWords(r); ok {
return words
}
if strings.HasPrefix(lower, "mirrors pr #") {
return "mirrors PR " + r[len("mirrors PR "):]
Expand Down Expand Up @@ -1379,9 +1384,6 @@ func humanizeStageReason(reason string) string {
if strings.HasPrefix(lower, "release-hold") {
return "release hold"
}
if strings.HasPrefix(lower, "status-") || strings.HasPrefix(lower, "check-") {
return "CI is red (" + r + ")"
}
switch lower {
case stageengineprstage.ContributorLaneReasonWorkflowPath:
return "workflow path"
Expand Down
2 changes: 1 addition & 1 deletion src/pkg/dashboard/stage_tracker_adopted_column.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const src = [
pick(/const STAGE_TRACKER_TERMINAL = \d+;/, 'STAGE_TRACKER_TERMINAL'),
pick(/const STAGE_TRACKER_ADOPTED_BY_HIVE = \d+;/, 'STAGE_TRACKER_ADOPTED_BY_HIVE'),
pick(/function stageTrackerAdoptedWord\(item\) \{[\s\S]*?\n \}\n/, 'stageTrackerAdoptedWord'),
pick(/function stageTrackerAnchor\(stage, stages, kind\) \{[\s\S]*?\n \}\n/, 'stageTrackerAnchor'),
pick(/function stageTrackerAnchor\(stage, stages, kind, item\) \{[\s\S]*?\n \}\n/, 'stageTrackerAnchor'),
].join('\n');
const lifted = new Function(src + '; return { anchor: stageTrackerAnchor, adoptedWord: stageTrackerAdoptedWord, ADOPTED: STAGE_TRACKER_ADOPTED_BY_HIVE };')();

Expand Down
37 changes: 37 additions & 0 deletions src/pkg/dashboard/stage_tracker_ci_words.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package dashboard

import "strings"

// stageTrackerCIStateWords renders a commit-CI reason token
// (github.CommitCIState.Reason: "check-pending", "status-pending",
// "check-<conclusion>", "status-<state>", "check-failing:<name>") as the
// state it names. Pending is not red: the tracker once captioned a 060
// row "CI is red (check-pending)" while its checks were still running
// (hivecommons/docs#512). ok is false for anything that is not a CI token.
func stageTrackerCIStateWords(reason string) (words string, ok bool) {
r := strings.TrimSpace(reason)
lower := strings.ToLower(r)
var kind, rest string
switch {
case strings.HasPrefix(lower, "check-"):
kind, rest = "check", r[len("check-"):]
case strings.HasPrefix(lower, "status-"):
kind, rest = "status", r[len("status-"):]
default:
return "", false
}
if name, found := strings.CutPrefix(rest, "failing:"); found {
return "CI failed: " + name, true
}
switch strings.ToLower(rest) {
case "pending", "queued", "in_progress", "waiting", "requested", "expected":
return "CI running", true
case "success":
return "CI green", true
case "failure", "error":
return "CI failed", true
case "neutral", "skipped":
return "CI skipped (" + kind + " " + strings.ToLower(rest) + ")", true
}
return "CI failed (" + strings.ReplaceAll(strings.ToLower(rest), "_", " ") + ")", true
}
135 changes: 135 additions & 0 deletions src/pkg/dashboard/stage_tracker_merge_failed_column_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
package dashboard

import (
"strings"
"testing"
)

// TestStageTrackerMergeFailedColumnNode: the operator's row
// (hivecommons/docs#496 β†’ docs#512, 2026-10-29 11:04 ET). The lane fell
// back to 060 after the automerge sweep's merge call drew GitHub's 405 "4
// of 4 required status checks are expected", and the tracker drew the amber
// "⟳ Merge failed · merge sweep running ⬑" chip in CI / Review with the raw
// "PUT https://api.github.com/…" error spilling out of it. A merge outcome
// always lights the Merge gate column; the chip is a fixed short phrase
// (no URL, no verb, ≀ 5 words) with GitHub's words in the tooltip's
// Details line; pending CI is "CI running", never "red"; and the cue
// names the stage in plain words, not "stage/060-reviewed".
func TestStageTrackerMergeFailedColumnNode(t *testing.T) {
html := indexHTML(t)
for _, want := range []string{
`if (mg && (mg.state === 'merging' || mg.state === 'merge-failed') && cur > STAGE_TRACKER_PR_COLUMN) return STAGE_TRACKER_MERGE_COLUMN;`,
`const anchor = stageTrackerAnchor(cur, stages, item.via_pr ? 'pr' : item.kind, item);`,
`stageTrackerAnchor(item.stage, stages, item.via_pr ? 'pr' : item.kind, item);`,
`label: (typeof stageTrackerStageName === 'function' && (stageTrackerStageName(tipStage) || stageTrackerStageName(st))) || tipStage.label || st.label || String(n)`,
`.ham-gate-detail { font-weight: normal; opacity: 0.85; white-space: nowrap; font-variant-numeric: tabular-nums; display: inline-block; vertical-align: bottom; max-width: 12em; overflow: hidden; text-overflow: ellipsis; }`,
} {
if !strings.Contains(html, want) {
t.Errorf("index.html missing merge-outcome column wiring %q", want)
}
}
runStageTrackerRowActionsScript(t, "function esc(s) { return String(s).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/\"/g, '&quot;'); }\n"+
jsConstLine(t, html, "STAGE_TRACKER_TERMINAL")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_PATH")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_PR_COLUMN")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_MERGE_COLUMN")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_PRE_MERGE_SOAK")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_NEEDS_DECISION")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_ISSUE_NEEDS_DECISION")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_ISSUE_DECISION_COLUMN")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_TRIAGE_NEEDED")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_POSSIBLY_EXISTS")+"\n"+
jsConstLine(t, html, "STAGE_TRACKER_MERGE_GATE_WORD")+"\n"+
jsConstBlock(t, html, "STAGE_TRACKER_GATE_REASON_WORDS")+"\n"+
jsConstBlock(t, html, "STAGE_TRACKER_EVENT_MOD_WORDS")+"\n"+
jsFunc(t, html, "stageTrackerAnchor")+"\n"+
jsFunc(t, html, "stageTrackerAgoText")+"\n"+
jsFunc(t, html, "stageTrackerSoakLeft")+"\n"+
jsFunc(t, html, "stageTrackerMergeGateStateOf")+"\n"+
jsFunc(t, html, "stageTrackerShortLeft")+"\n"+
jsFunc(t, html, "stageTrackerGateReasonText")+"\n"+
stageTrackerMergeGateInfoJS(t, html)+"\n"+
jsFunc(t, html, "stageTrackerMergeGateWordHtml")+"\n"+
jsFunc(t, html, "stageTrackerStageName")+"\n"+
jsFunc(t, html, "stageTrackerStageFell")+"\n"+
jsFunc(t, html, "stageTrackerEventText")+"\n"+`
const assert = require('assert');
const now = Date.parse('2026-10-29T15:04:00Z');
const iso = ms => new Date(ms).toISOString();
const stages = [{ number: 50, label: 'stage/050-review-pending', short: 'CI / Review' }, { number: 60, label: 'stage/060-reviewed', short: '' }, { number: 80, label: 'stage/080-awaiting-merge', short: 'Merge gate' }];
const raw = 'PUT https://api.github.com/repos/hivecommons/docs/pulls/512/merge: 405 4 of 4 required status checks are expected. []';
const gate = (extra) => Object.assign({ state: 'merge-failed', reason: 'check-pending', sweep_running: true, merge_path: 'sweep', merge_failed: raw, merge_failed_at: iso(now - 60000), next_sweep_at: iso(now + 7000), last_sweep_at: iso(now - 22000) }, extra || {});
const row = (mg) => ({ repo: 'hivecommons/docs', number: 512, kind: 'pr', stage: 60, stage_label: 'stage/060-reviewed', reason: 'check-pending', modifiers: [], merge_gate: mg });
const words = s => s.trim().split(/\s+/).filter(w => w !== 'Β·');
const plain = s => !/http|\bPUT\b|api\.github\.com/i.test(s);

// 1. Column: the merge outcome lights Merge gate (80), whatever stage the
// lane fell back to; the same stage without a merge call stays in CI /
// Review (50); a merged / open row is unaffected.
assert.strictEqual(stageTrackerAnchor(60, stages, 'pr', row(gate())), STAGE_TRACKER_MERGE_COLUMN, 'merge-failed at 060 β†’ Merge gate');
assert.strictEqual(stageTrackerAnchor(60, stages, 'pr', row(gate({ state: 'merging', merge_failed: '' }))), STAGE_TRACKER_MERGE_COLUMN, 'merging at 060 β†’ Merge gate');
assert.strictEqual(stageTrackerAnchor(50, stages, 'pr', row(gate())), STAGE_TRACKER_MERGE_COLUMN, 'merge-failed at 050 β†’ Merge gate');
assert.strictEqual(stageTrackerAnchor(60, stages, 'pr', row({ state: 'gate-pending', reason: 'check-pending' })), 50, 'no merge call: 060 stays in CI / Review');
assert.strictEqual(stageTrackerAnchor(60, stages, 'pr'), 50, 'no item: unchanged');
assert.strictEqual(stageTrackerAnchor(STAGE_TRACKER_TERMINAL, stages, 'pr', row(gate())), STAGE_TRACKER_TERMINAL);
assert.strictEqual(stageTrackerAnchor(30, stages, 'pr', row(gate())), 30, 'a stale gate on a PR back in progress does not jump it forward');

// 2. The chip for this exact payload (Go translated the 405): the sweep
// called too early, so it is "Waiting for CI Β· 4 checks", not a failure.
let info = stageTrackerMergeGateInfo(row(gate({ merge_failed_kind: 'checks-pending', merge_failed_text: "4 required checks haven't finished", merge_failed_checks: 4 })), now);
assert.strictEqual(info.word, 'Waiting for CI');
assert.strictEqual(info.detail, '4 checks');
assert.strictEqual(info.cue, 'running', 'the sweep is on it');
assert.ok(info.tip.includes("before its required checks had reported β€” 4 required checks haven't finished"), info.tip);
assert.ok(info.tip.includes('Details: ' + raw), 'raw error only after Details: ' + info.tip);
assert.ok(!info.tip.startsWith('stage/'), info.tip);
// Older payload without the translated fields: the SPA classifies the raw text itself.
info = stageTrackerMergeGateInfo(row(gate()), now);
assert.strictEqual(info.word + ' Β· ' + info.detail, 'Waiting for CI Β· 4 checks', 'raw-only payload');
assert.ok(info.tip.includes("4 required checks haven't finished"), info.tip);

// 3. Every merge-failed chip is a fixed short phrase: no URL, no verb, ≀ 5 words.
const cases = [
[gate(), 'Waiting for CI Β· 4 checks'],
[gate({ sweep_running: false }), 'Waiting for CI Β· 4 checks'],
[gate({ merge_failed: '405 Pull Request is not mergeable' }), 'Merge failed Β· retrying'],
[gate({ merge_failed: '405 Pull Request is not mergeable', sweep_running: false }), 'Merge failed Β· branch protection'],
[gate({ merge_failed: '409 Head branch was modified. Review and try the merge again.', sweep_running: false }), 'Merge failed Β· needs rebase'],
[gate({ merge_failed: '403 Resource not accessible by integration', sweep_running: false }), 'Merge failed Β· not allowed'],
[gate({ merge_failed: 'context deadline exceeded', sweep_running: false }), 'Merge failed Β· GitHub refused'],
[gate({ merge_failed: 'context deadline exceeded', merge_failed_kind: 'refused', merge_failed_text: 'GitHub refused the merge', sweep_running: false }), 'Merge failed Β· GitHub refused'],
[gate({ merge_failed: '405 At least 1 approving review is required', merge_failed_kind: 'review', merge_failed_text: "branch protection wants an approving review hive can't give", sweep_running: false }), 'Merge failed Β· review required'],
[gate({ merge_failed: '', sweep_running: false }), 'Merge failed Β· GitHub refused'],
];
for (const [mg, want] of cases) {
const i = stageTrackerMergeGateInfo(row(mg), now);
const label = i.word + (i.detail ? ' Β· ' + i.detail : '');
assert.strictEqual(label, want);
assert.ok(plain(label), 'no raw error in the chip: ' + label);
assert.ok(words(label).length <= 5, 'chip ≀ 5 words: ' + label);
const html = stageTrackerMergeGateWordHtml(row(mg), now);
assert.ok(html.includes('<span class="ham-seg-t">') && plain(html), html);
if (mg.merge_failed) assert.ok(i.tip.includes('Details: ' + mg.merge_failed), 'raw text rides the tooltip: ' + i.tip);
}
// A retry says what GitHub said in the tooltip.
info = stageTrackerMergeGateInfo(row(gate({ merge_failed: '405 Pull Request is not mergeable' })), now);
assert.ok(info.tip.includes('GitHub refused β€” branch protection blocks it') && info.tip.includes("merge sweep is retrying it now"), info.tip);
assert.strictEqual(info.cue, 'running');

// 4. Pending CI is not red.
assert.strictEqual(stageTrackerGateReasonText('check-pending'), 'CI running');
assert.strictEqual(stageTrackerGateReasonText('required-check-pending:build'), 'CI running (build)');
assert.strictEqual(stageTrackerGateReasonText('check-failing:unit'), 'CI failed: unit');
assert.strictEqual(stageTrackerGateReasonText('required-check-failing'), 'CI failed');

// 5. The cue names the stage in words, never by its slug.
assert.strictEqual(stageTrackerStageName({ label: 'stage/060-reviewed' }), 'Reviewed');
assert.strictEqual(stageTrackerStageName({ label: '060-reviewed', short: 'Review passed' }), 'Review passed');
assert.strictEqual(stageTrackerStageName({ label: 'Claimed' }), 'Claimed');
assert.strictEqual(stageTrackerStageName(null), '');
const snap = (stage, label, caption) => ({ stage, label, caption: caption || '', mods: [] });
assert.strictEqual(stageTrackerEventText(snap(80, 'stage/080-awaiting-merge'), snap(60, 'stage/060-reviewed', 'Review passed; waiting for merge admission β€” CI running'), stages), 'fell back to Reviewed β€” Review passed; waiting for merge admission β€” CI running');
assert.strictEqual(stageTrackerEventText(snap(50, ''), snap(80, ''), stages), 'moved to Merge gate', 'short word when the table has one');
console.log('ok');
`)
}
9 changes: 9 additions & 0 deletions src/pkg/dashboard/stage_tracker_merge_gate.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@ type StageTrackerMergeGate struct {
// state merge-failed.
MergeFailed string `json:"merge_failed,omitempty"`
MergeFailedAt *time.Time `json:"merge_failed_at,omitempty"`
// MergeFailedKind / MergeFailedText / MergeFailedChecks: the refusal
// translated (stageTrackerMergeRefusal) β€” a kind token the SPA maps to
// a short chip detail, the plain sentence for the tooltip, and for
// checks-pending how many required checks are still expected. The raw
// MergeFailed text is for the tooltip's Details line only.
MergeFailedKind string `json:"merge_failed_kind,omitempty"`
MergeFailedText string `json:"merge_failed_text,omitempty"`
MergeFailedChecks int `json:"merge_failed_checks,omitempty"`
}

// stageTrackerMergeGateState maps a stage to its merge-gate state; "" off
Expand Down Expand Up @@ -174,6 +182,7 @@ func stageTrackerMergeGateAttempt(mg *StageTrackerMergeGate, a github.MergeAttem
mg.MergingSince = &since
mg.MergePath = a.Path
mg.MergeFailed = a.Error
mg.MergeFailedKind, mg.MergeFailedText, mg.MergeFailedChecks = stageTrackerMergeRefusal(a.Error)
at := a.EndedAt
mg.MergeFailedAt = &at
}
Expand Down
Loading
Loading