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-decision-toast-issue-wording.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Let-hive-decide toast: an issue decision no longer reads as "approved for merge".** On hive's own spoke, issue #15021 (`approved-direction` applied, `stage/045-needs-decision` never removed) produced the toast "Hive decided on hivecommons/hive#15021: decided, but it hasn't taken effect … Hive decided **approved for merge** at 2026-10-28T20:41:22Z". Nothing merges on an issue. The decision glossary (`pkg/delegatedecision`) now carries issue words beside the PR words for every decision kind that differs β€” `approve` β†’ PR "approved for merge" / issue "approved to proceed β€” an agent may claim it"; `direction`, `close-superseded` and the `hold` reason likewise β€” and `ActionPlainOn` / `PlainOn` / `DetailOn` select by item kind in the toast, the `/hive decision` comment and the stalled follow-up (the SPA mirror `stageTrackerPlainWords(slug, detail, itemKind)` does the same). The headline no longer says "decided … decided" ("no effect yet"), and the SPA rewrites the server's RFC3339 stamps into the operator's clock ("2h ago (4:41 PM)") through the shared timezone helper. When the hive can see the real cause β€” the 045 park label still on an issue that already carries `approved-direction` β€” the toast says so ("stage/045-needs-decision is still on the issue; the scanner skips it until that label clears") and offers the fix first: **Lift the park (remove stage/045-needs-decision)** runs the audited issue-decision path that removes the label and tells the stage engine the park lifted, followed by Re-evaluate now, Re-run decision and Give direction.
2 changes: 1 addition & 1 deletion src/pkg/dashboard/api_repo_item_decide_delegated.go
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ func (s *Server) decideDelegatedOne(ctx context.Context, repoFull string, number
now := delegatedDecisionNow()
timeout := s.delegatedEffectTimeout()
why := s.delegatedStuckWhy(in, d, req, prior)
options := delegatedStuckOptions(in, d, mergerRole)
options := delegatedStuckOptions(in, d, mergerRole, why)
res := delegatedDecisionEffectResult(rowActionTarget(repoFull, kind, number), in, d, prior.At, now, timeout, why, options)
notes := append(deciderNotes, "already applied; nothing written")
noop := "already-applied"
Expand Down
58 changes: 57 additions & 1 deletion src/pkg/dashboard/api_repo_item_decide_delegated_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ func TestDelegatedDecisionStuckReportsNoEffect(t *testing.T) {
}
res := job.Result
t.Logf("outcome: %s\nnext: %s\nwhy: %s", res.Outcome, res.Next, res.Why)
for _, want := range []string{"Hive decided close this PR and open a fresh hive-authored PR with the same commits at 2026-10-28T12:01:00Z", "but it hasn't taken effect:"} {
for _, want := range []string{"Close this PR and open a fresh hive-authored PR with the same commits at 2026-10-28T12:01:00Z", "but it hasn't taken effect:"} {
if !strings.Contains(res.Outcome, want) {
t.Fatalf("outcome %q missing %q", res.Outcome, want)
}
Expand Down Expand Up @@ -619,6 +619,55 @@ func TestReparkFromEvents(t *testing.T) {
}
}

// TestDelegatedDecisionStuckIssueWording reproduces hivecommons/hive#15021:
// the hive approved an ISSUE (`default-approve`), approved-direction landed
// but stage/045-needs-decision never came off. Past the effect timeout the
// toast must not say "approved for merge" (nothing merges on an issue),
// must name the stuck label, and must offer the lift first.
func TestDelegatedDecisionStuckIssueWording(t *testing.T) {
pinDelegatedClock(t, "2026-10-28T22:00:00Z")
prior := delegatedecision.Decision{Verdict: delegatedecision.VerdictApprove, Rule: "default-approve", Text: "approve", Rationale: "default"}
mock := &repoItemDecisionMock{issueLabels: []string{"help wanted", "triage/accepted", "approved-direction", "stage/045-needs-decision"}}
mock.priorComments = []string{delegatedecision.CommentBodyWith(prior, "h1", "writer", delegatedecision.CommentOptions{Kind: delegatedecision.KindIssue})}
srv := newDelegatedServer(t, mock)
w := postDelegated(t, srv, 7, "writer", `{"type":"issue","reason":"needs-decision","caption":"Needs decision"}`, nil)
if w.Code != http.StatusOK {
t.Fatalf("code=%d body=%s", w.Code, w.Body.String())
}
job := decodeDelegatedJob(t, w)
if job.Result == nil || job.Result.Action != rowActionNoEffect {
t.Fatalf("result = %+v notes=%v", job.Result, job.Notes)
}
res := job.Result
t.Logf("outcome: %s\nnext: %s\nwhy: %s", res.Outcome, res.Next, res.Why)
if res.Why != delegatedecision.GlossaryParkLabelStuck {
t.Fatalf("why = %q", res.Why)
}
for _, bad := range []string{"approved for merge", "merge gate", "Hive decided"} {
if strings.Contains(res.Outcome, bad) {
t.Fatalf("PR wording / repeated headline in issue outcome %q: %q", res.Outcome, bad)
}
}
for _, want := range []string{"Approved to proceed β€” an agent may claim it at 2026-10-28T", "stage/045-needs-decision is still on the issue"} {
if !strings.Contains(res.Outcome, want) {
t.Fatalf("outcome %q missing %q", res.Outcome, want)
}
}
if !strings.Contains(res.Next, "approved-direction") || !strings.Contains(res.Next, "Lift the park") {
t.Fatalf("next = %q", res.Next)
}
if len(res.Options) < 4 || res.Options[0].Action != decisionActionApprove || !res.Options[0].Enabled || res.Options[1].Action != decisionActionRetry {
t.Fatalf("options = %+v", res.Options)
}
if labels := strings.Join(optionLabels(res.Options), "|"); !strings.Contains(labels, "Re-run decision") || !strings.Contains(labels, "Give direction") || strings.Contains(labels, "Merge as maintainer") {
t.Fatalf("options = %q", labels)
}
// The follow-up comment carries the issue words too.
if len(mock.comments) != 1 || strings.Contains(mock.comments[0], "approved for merge") || !strings.Contains(mock.comments[0], "approved to proceed") {
t.Fatalf("comments = %v", mock.comments)
}
}

// TestDelegatedStuckWhyReadsTheLane covers the why derivation per lane
// reason and verdict so every stuck decision gets a specific plain reason.
func TestDelegatedStuckWhyReadsTheLane(t *testing.T) {
Expand Down Expand Up @@ -647,6 +696,13 @@ func TestDelegatedStuckWhyReadsTheLane(t *testing.T) {
{"hold", pr, approve, delegatedDecisionRequest{Reason: "hold"}, selfApprove, delegatedecision.GlossaryHold},
{"pr fallback", pr, approve, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryNotMergedYet},
{"issue fallback", issue, approve, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryStillParked},
{"issue park label outlived the approval", delegatedecision.Input{Kind: delegatedecision.KindIssue, Labels: []string{"help wanted", "approved-direction", "stage/045-needs-decision"}}, approve, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryParkLabelStuck},
{"issue park label without the ack is just parked", delegatedecision.Input{Kind: delegatedecision.KindIssue, Labels: []string{"stage/045-needs-decision"}}, approve, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryStillParked},
{"pr with both labels is not the issue case", func() delegatedecision.Input {
i := pr
i.Labels = []string{"approved-direction", "stage/045-needs-decision"}
return i
}(), approve, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryNotMergedYet},
{"close fallback", pr, delegatedecision.Decision{Verdict: delegatedecision.VerdictCloseSuperseded}, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryNotClosedYet},
{"direction fallback", pr, delegatedecision.Decision{Verdict: delegatedecision.VerdictDirection}, delegatedDecisionRequest{}, selfApprove, delegatedecision.GlossaryNoNewCommit},
}
Expand Down
44 changes: 39 additions & 5 deletions src/pkg/dashboard/delegated_decision_effect.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/hivecommons/hive/pkg/config"
"github.com/hivecommons/hive/pkg/delegatedecision"
ghpkg "github.com/hivecommons/hive/pkg/github"
"github.com/hivecommons/hive/pkg/stagelabels"
)

// Stuck-decision detection for "Let hive decide" (hivecommons/hive#14822).
Expand Down Expand Up @@ -199,13 +200,35 @@ func (s *Server) delegatedStuckWhy(in delegatedecision.Input, d delegatedecision
return delegatedecision.GlossaryNotClosedYet
case d.Verdict == delegatedecision.VerdictDirection:
return delegatedecision.GlossaryNoNewCommit
case issueParkLabelStuck(in, d):
return delegatedecision.GlossaryParkLabelStuck
case in.Kind == delegatedecision.KindIssue:
return delegatedecision.GlossaryStillParked
default:
return delegatedecision.GlossaryNotMergedYet
}
}

// issueParkLabelStuck reports the case seen on hivecommons/hive#15021: the
// hive approved an issue and `approved-direction` landed, but the
// stage/045-needs-decision park label never came off, so the scanner keeps
// skipping the issue. The toast names the label and offers the lift.
func issueParkLabelStuck(in delegatedecision.Input, d delegatedecision.Decision) bool {
if in.Kind != delegatedecision.KindIssue || d.Verdict != delegatedecision.VerdictApprove {
return false
}
park, ack := false, false
for _, l := range in.Labels {
switch {
case strings.EqualFold(strings.TrimSpace(l), stagelabels.IssueNeedsDecision.Label()):
park = true
case strings.EqualFold(strings.TrimSpace(l), ghpkg.HumanAckLabel):
ack = true
}
}
return park && ack
}

// isApproveDecisionText reports a bare `/hive decision approve[d]`.
func isApproveDecisionText(line string) bool {
rest := strings.TrimSpace(strings.TrimPrefix(strings.TrimSpace(line), "/hive decision"))
Expand All @@ -220,9 +243,17 @@ func isApproveDecisionText(line string) bool {
// delegatedStuckOptions are the concrete next actions for a decision that
// has not taken effect, in the popover's option shape so the SPA renders
// them as buttons. Merging is the in-tracker merge-now action
// (hivecommons/hive#15087) for a merger, not a link out.
func delegatedStuckOptions(in delegatedecision.Input, d delegatedecision.Decision, mergerRole bool) []StageTrackerDecisionOption {
// (hivecommons/hive#15087) for a merger, not a link out. When why is the stuck 045 park
// label, the first option lifts it: `decide:approve` on an issue runs
// RecordOperatorIssueDecision, the audited path that removes the park
// label and tells the stage engine the park lifted.
func delegatedStuckOptions(in delegatedecision.Input, d delegatedecision.Decision, mergerRole bool, why string) []StageTrackerDecisionOption {
var opts []StageTrackerDecisionOption
if why == delegatedecision.GlossaryParkLabelStuck {
opts = append(opts,
StageTrackerDecisionOption{Action: decisionActionApprove, Label: "Lift the park (remove " + stagelabels.IssueNeedsDecision.Label() + ")", Enabled: true},
StageTrackerDecisionOption{Action: decisionActionRetry, Label: "Re-evaluate now", Enabled: true})
}
if in.Kind == delegatedecision.KindPR && d.Verdict != delegatedecision.VerdictCloseDuplicate && d.Verdict != delegatedecision.VerdictCloseSuperseded {
o := decisionOption(decisionActionMergeNow, "Merge as maintainer", mergerRole, decisionWhyMergerRole)
o.Consequence = "merges #" + strconv.Itoa(in.Number) + " now via hive's identity, attributed to you"
Expand Down Expand Up @@ -255,7 +286,7 @@ func delegatedDecisionEffectResult(target RowActionTarget, in delegatedecision.I
eff := delegatedecision.ExpectedEffect(d, in.Kind)
at := prior.UTC().Truncate(time.Second)
stamp := at.Format(time.RFC3339)
plainAction := delegatedecision.ActionPlain(d)
plainAction := delegatedecision.ActionPlainOn(d, in.Kind)
out := RowActionResult{Target: target, Rule: d.Rule, AppliedAt: &at, Why: why}
if !eff.Waits {
out.Action = rowActionNoop
Expand All @@ -272,8 +303,11 @@ func delegatedDecisionEffectResult(target RowActionTarget, in delegatedecision.I
}
out.Action = rowActionNoEffect
out.Options = options
out.Outcome = "Hive decided " + plainAction + " at " + stamp + ", but it hasn't taken effect: " + delegatedecision.Plain(why) + "."
next := "Expected: " + eff.What + ". " + delegatedecision.Detail(why)
// The toast headline already says "Hive decided on <item>"; the body
// does not say "decided" again. The SPA rewrites the RFC3339 stamp into
// the operator's clock (stageTrackerStampWords).
out.Outcome = delegatedecision.CapitalizeFirst(plainAction) + " at " + stamp + ", but it hasn't taken effect: " + delegatedecision.PlainOn(why, in.Kind) + "."
next := "Expected: " + eff.What + ". " + delegatedecision.DetailOn(why, in.Kind)
if labels := optionLabels(options); len(labels) > 0 {
next += " Options: " + strings.Join(labels, " Β· ") + "."
}
Expand Down
25 changes: 22 additions & 3 deletions src/pkg/dashboard/stage_tracker_row_actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ func stageTrackerRowActionsPreamble(t *testing.T, html string) string {
jsConstLine(t, html, "STAGE_TRACKER_MENU_FAIL_LINES"),
jsConstBlock(t, html, "STAGE_TRACKER_DECISION_GLOSSARY"),
jsFunc(t, html, "stageTrackerPlainWords"),
jsFunc(t, html, "stageTrackerShortAgo"),
jsConstBlock(t, html, "STAGE_TRACKER_ACTION_LABELS"),
jsConstLine(t, html, "STAGE_TRACKER_WHY_WRITE"),
jsConstLine(t, html, "STAGE_TRACKER_WHY_ROLE"),
Expand Down Expand Up @@ -1033,16 +1034,34 @@ assert.ok(text.outcome.startsWith('No change β€” hive already recorded this deci
// hivecommons/hive#14822: a recorded decision that never took effect is a
// warning that says why in plain words and carries the next actions.
const stuck = { action: 'no-effect', rule: 'contributor-offline', why: 'self-decision-read-as-changes', target, applied_at: '2026-10-28T13:01:29Z',
outcome: "Hive decided close this PR and open a fresh hive-authored PR with the same commits at 2026-10-28T13:01:29Z, but it hasn't taken effect: hive's own decision comment was read as a reviewer asking for changes.",
outcome: "Close this PR and open a fresh hive-authored PR with the same commits at 2026-10-28T13:01:29Z, but it hasn't taken effect: hive's own decision comment was read as a reviewer asking for changes.",
next: 'Options: Merge as maintainer Β· Re-run decision Β· Close as superseded Β· Send back for a new commit.',
options: [{ action: 'decide:merge-now', label: 'Merge as maintainer', enabled: true }, { action: 'decide:delegate:rerun', label: 'Re-run decision', enabled: true }, { action: 'decide:close-superseded', label: 'Close as superseded', enabled: false, reason_if_disabled: 'write required' }, { action: 'decide:direction', label: 'Send back for a new commit', enabled: true }, { label: 'no action' }] };
text = stageTrackerResultText(stuck, issue, { id: 'decide:delegate' });
assert.strictEqual(text.head, "Hive decided on o/r#14938 β†’ PR #14947: decided, but it hasn't taken effect (the author's clanker hasn't been connected since the nudge)");
const stuckNow = Date.parse('2026-10-28T15:01:29Z');
text = stageTrackerResultText(stuck, issue, { id: 'decide:delegate', nowMs: stuckNow });
assert.strictEqual(text.head, "Hive decided on o/r#14938 β†’ PR #14947: no effect yet (the author's clanker hasn't been connected since the nudge)", 'the headline does not say "decided" twice');
assert.strictEqual(text.type, 'warning'); assert.strictEqual(text.options.length, 4, 'options without an action are dropped');
// The raw RFC3339 stamp never reaches the operator (#15126).
assert.ok(!/2026-10-28T13:01:29Z/.test(text.outcome) && / at 13:01( today)?, but/.test(text.outcome), text.outcome);
assert.ok(text.why.startsWith('The merge gate read the hive'), text.why);
assert.ok(!/contributor-offline|self-decision/.test(text.head + text.outcome + text.why), 'no bare slug reaches the operator');
// hivecommons/hive#15021: an ISSUE's approve is never "approved for merge",
// and a stuck 045 park label is named with the lift as the first option.
const issueTarget = { repo: 'o/r', kind: 'issue', number: 15021, url: 'u15021' };
const stuckIssue = { action: 'no-effect', rule: 'default-approve', why: 'park-label-stuck', target: issueTarget, applied_at: '2026-10-28T13:01:29Z',
outcome: "Approved to proceed β€” an agent may claim it at 2026-10-28T13:01:29Z, but it hasn't taken effect: stage/045-needs-decision is still on the issue; the scanner skips it until that label clears.",
next: 'Expected: the issue leaves Needs decision and an agent picks it up. Options: Lift the park (remove stage/045-needs-decision) Β· Re-evaluate now Β· Re-run decision Β· Give direction.',
options: [{ action: 'decide:approve', label: 'Lift the park (remove stage/045-needs-decision)', enabled: true }, { action: 'retry', label: 'Re-evaluate now', enabled: true }, { action: 'decide:delegate:rerun', label: 'Re-run decision', enabled: true }, { action: 'decide:direction', label: 'Give direction', enabled: true }] };
text = stageTrackerResultText(stuckIssue, Object.assign({}, issue, { kind: 'issue', number: 15021 }), { id: 'decide:delegate', rowRef: 'o/r#15021', nowMs: stuckNow });
assert.strictEqual(text.head, 'Hive decided on o/r#15021: no effect yet (no special rule applies; the hive took its own recommendation)');
assert.ok(text.outcome.indexOf('approved for merge') < 0, text.outcome);
assert.ok(text.why.startsWith('The hive approved the issue and applied approved-direction'), text.why);
assert.strictEqual(text.options[0].action, 'decide:approve', 'the lift is the first option');
assert.strictEqual(stageTrackerPlainWords('approve', false, 'issue'), 'approved to proceed β€” an agent may claim it');
assert.strictEqual(stageTrackerPlainWords('approve', false, 'pr'), 'approved for merge');
assert.strictEqual(stageTrackerPlainWords('approve'), 'approved for merge', 'no kind reads as a PR');
assert.strictEqual(stageTrackerPlainWords('close-superseded', true, 'issue'), 'Closed because another issue already tracks the same work; the discussion continues there.');
assert.strictEqual(stageTrackerPlainWords('close-duplicate', false, 'issue'), 'closed as a duplicate', 'an entry without issue words keeps its plain words');
assert.strictEqual(stageTrackerPlainWords('supersede'), 'close this PR and open a fresh hive-authored PR with the same commits');
assert.strictEqual(stageTrackerPlainWords('adoption-stalled:contributor-offline'), "the author's clanker hasn't been connected since the nudge");
assert.strictEqual(stageTrackerPlainWords('contributor-lane:changes-requested'), stageTrackerPlainWords('changes_requested'));
Expand Down
Loading
Loading