diff --git a/changelog.d/fixed-blocked-needs-marker.md b/changelog.d/fixed-blocked-needs-marker.md new file mode 100644 index 0000000000..700691f190 --- /dev/null +++ b/changelog.d/fixed-blocked-needs-marker.md @@ -0,0 +1 @@ +- A `blocked` label that names nothing is no longer a dead end. A contributor relay's blocked verdict that named no issue or PR used to leave `blocked` with no marker: before 10-28 the sweep lifted it and the next relay re-blocked it (projectbluefin/utah#771 cycled 19 times); since then it stuck and the issue showed in no inbox ("labelled blocked — the label records no reason"). The blocked sweep now turns such a hive-applied block into a `needs-human` ask with one note, a verdict whose reason is empty or only the relay footer is booked idle with its label released (projectbluefin/utah#1002), and a blocked-on marker in a comment (projectbluefin/finpilot#624, #390) now names the blocker in the row reason and the band signal. diff --git a/src/docs/labels-and-control-signals/reference.md b/src/docs/labels-and-control-signals/reference.md index 1fab70ff32..65494041ec 100644 --- a/src/docs/labels-and-control-signals/reference.md +++ b/src/docs/labels-and-control-signals/reference.md @@ -94,7 +94,7 @@ Some hive-authored labels look like provenance but are read as signals, so they | `needs-sha` from SHA-hold | Issues | SHA-hold sweep | Trusted-reporter `kind/bug` without a SHA gets this soft label plus the same `` notice instead of `hold`; the issue stays actionable. The sweep removes it once a SHA appears. | Soft (informational) | Hive | Eval tick SHA sweep | Add SHA evidence, or remove the label | `issues.sha_hold_trusted_label` (default `needs-sha`; `hold` restores the hard hold for everyone) | | `do-not-merge` and `do-not-merge*` | Issues, PRs | Exempt filter, merge sweeps, task-list sweep | Permanently exempt; exact match is case-insensitive but prefix matching follows Go `strings.HasPrefix` on the original label. | Hard suppress | Human | Enumeration/sweeps | Human removes | Built-in `PermanentExemptLabels` (`src/pkg/github/client.go:750-755`, `src/pkg/github/client.go:2035-2053`) | | `governor.labels.exempt` entries | Issues, PRs | Exempt filter | Same exempt behavior as `do-not-merge`; wins over required-label admission. Defaults include `nightly-tests`, `LFX`, `meta-tracker`, `auto-qa-tuning-report`, `adopters`, `changes-requested`, `waiting-on-author`. | Hard suppress | Operator/dashboard | Enumeration/sweeps | Remove label or config entry | `governor.labels.exempt` (`src/pkg/config/governor_config.go:175-184`, `src/pkg/config/defaults.go:260-270`) | -| `blocked` | Issues | Enumeration, stage derivation, claim gate, review backlog, blocked sweep | The issue waits on an unmerged PR (or another outside blocker): the review backlog files a finding `blocked` when its evidence file exists only on the reviewed PR (absent on the base branch), and `hive-open-issue comment --blocked-on-pr ` parks an existing one; both write ``. A `blocked` issue is filtered (reason `blocked on owner/repo#N`), derives no stage label, is refused by every automated claim producer (`blocked: owner/repo#N`) including the contributor relay, and never carries `help wanted` ([#13093](https://github.com/hivecommons/hive/issues/13093)). When a blocked filing folds into an already-open twin, the twin's own state governs: `blocked` is not applied to it, because the folded body (and its marker) is discarded and the twin's earlier evidence stands on its own; the blocked sweep also lifts a hive-applied `blocked` that has no marker, no deadline and no ops-tracking marker, but only on a review-backlog item (its body carries `filed by Hive review backlog`) that GitHub reports no open "blocked by" link on ([#13364](https://github.com/hivecommons/hive/issues/13364)). Every other marker-less `blocked` stays: a human's, and a contributor relay's `blocked` verdict, which GitHub records as the App bot too because the relay labels with its hub-minted task token and which a person lifts (`/hive approve`, [#7924](https://github.com/hivecommons/hive/issues/7924)); lifting it only sent the issue back to the next agent, which re-applied it. With no blocked-on marker, a body deadline `` files it `blocked until ` and the activity monitor's blocked chip reads `re-check at ` ([#13310](https://github.com/hivecommons/hive/issues/13310)). | Hard suppress | Hive (reserved for agents; relay only) | Review backlog filing; blocked-on comment relay | The blocked sweep after each stage-label sync removes it, with one `` note, once the tracked PR is merged or closed, or once a recheck-after deadline passes (`deadline passed; re-triaging`) unless the body also carries ``. An ops-tracking issue on the hive's own project keeps `blocked` once its deadline passes and instead gets soak triage: the hub's `/api/hub/hives` (or, with no hub, the spoke's own `/api/version`) is probed for every `stable`-channel hive (fresh heartbeat, no restart loop, running the candidate `sha256:` digest or `v5 ` named in the body), ONE `` comment is posted, only the checklist lines that evidence proves are ticked, and `` is appended to the body so the sweep does not repeat ([#13311](https://github.com/hivecommons/hive/issues/13311)); a human may remove it at any time | Fixed label (`src/pkg/github/issue_blocked.go`, `src/pkg/github/issue_recheck_soak.go`, `src/pkg/github/issue_stage_labels.go`, `src/pkg/github/issue_claim_gate.go`) | +| `blocked` | Issues | Enumeration, stage derivation, claim gate, review backlog, blocked sweep | The issue waits on an unmerged PR (or another outside blocker): the review backlog files a finding `blocked` when its evidence file exists only on the reviewed PR (absent on the base branch), and `hive-open-issue comment --blocked-on-pr ` parks an existing one; both write ``. A `blocked` issue is filtered (reason `blocked on owner/repo#N`), derives no stage label, is refused by every automated claim producer (`blocked: owner/repo#N`) including the contributor relay, and never carries `help wanted` ([#13093](https://github.com/hivecommons/hive/issues/13093)). When a blocked filing folds into an already-open twin, the twin's own state governs: `blocked` is not applied to it, because the folded body (and its marker) is discarded and the twin's earlier evidence stands on its own; the blocked sweep also lifts a hive-applied `blocked` that has no marker, no deadline and no ops-tracking marker, but only on a review-backlog item (its body carries `filed by Hive review backlog`) that GitHub reports no open "blocked by" link on ([#13364](https://github.com/hivecommons/hive/issues/13364)). A human's marker-less `blocked` stays. A contributor relay's `blocked` verdict that named nothing (GitHub records it as the App bot too, because the relay labels with its hub-minted task token) is turned into a `needs-human` ask instead: `needs-human` is added, `blocked` removed and one note says what is missing. Lifting it only sent the issue back to the next agent, which re-applied it, and keeping it hid the issue from every inbox. A blocked verdict whose reason is empty or only the relay footer is booked idle and its label released, like a tooling failure. A marker in a comment counts like one in the body: the row's reason (`blocked on owner/repo#N`) and the band signal name it. With no blocked-on marker, a body deadline `` files it `blocked until ` and the activity monitor's blocked chip reads `re-check at ` ([#13310](https://github.com/hivecommons/hive/issues/13310)). | Hard suppress | Hive (reserved for agents; relay only) | Review backlog filing; blocked-on comment relay | The blocked sweep after each stage-label sync removes it, with one `` note, once the tracked PR is merged or closed, or once a recheck-after deadline passes (`deadline passed; re-triaging`) unless the body also carries ``. An ops-tracking issue on the hive's own project keeps `blocked` once its deadline passes and instead gets soak triage: the hub's `/api/hub/hives` (or, with no hub, the spoke's own `/api/version`) is probed for every `stable`-channel hive (fresh heartbeat, no restart loop, running the candidate `sha256:` digest or `v5 ` named in the body), ONE `` comment is posted, only the checklist lines that evidence proves are ticked, and `` is appended to the body so the sweep does not repeat ([#13311](https://github.com/hivecommons/hive/issues/13311)); a human may remove it at any time | Fixed label (`src/pkg/github/issue_blocked.go`, `src/pkg/github/issue_recheck_soak.go`, `src/pkg/github/issue_stage_labels.go`, `src/pkg/github/issue_claim_gate.go`) | | `needs-human` | Issues | Enumeration, task-list sweep, claim escalation gate and un-park sweep | Filters issues from agent kicks and contributor offers; records a human decision requirement. See the [issue reference](#needs-human) and [Maintainer commands](../maintainer-commands.md). | Hard suppress | Hive or human | Enumeration/task-list sweep/kick building | An eligible maintainer's ordinary `/hive approve` or `/hive decision ` lifts it regardless of who applied it; label-driven un-parking remains provenance-sensitive. Keep `hold` if work must stay stopped. Agents may add, never remove it. | Fixed label (`src/pkg/github/client.go:1008-1024`, `src/pkg/github/task_list_sweep.go:611-641`, `src/pkg/github/task_list_sweep.go:874-880`, `src/cmd/hive/claimescalation.go`) | | `needs-spec` from the clarity gate | Issues | Scheduler kick assembly (`runs.triage.clarity_gate`) | With the gate on (default off), a human-filed, unclaimed issue whose clarity score (goal, acceptance criteria, scope, detail, open choices) is under `runs.triage.clarity_gate.threshold` gets one `` comment with concise questions for its author and the `needs-spec` hard-suppress label instead of a claim; it derives `stage/045-needs-decision` and leaves the agent queue ([#13577](https://github.com/hivecommons/hive/issues/13577)). | Hard suppress | Hive | Before kicks are built | The issue author, or a non-hive commenter with write/maintain/admin, replies after the marker and the resume sweep removes the hive's own `needs-spec` and records the un-park so the issue re-derives `stage/010-actionable` ([#13588](https://github.com/hivecommons/hive/issues/13588)); a `needs-spec` a person added is never lifted by the sweep. Or remove `needs-spec` by hand. The marker keeps the gate from asking again | `runs.triage.clarity_gate` (`src/pkg/scheduler/clarity_gate.go`, `src/pkg/classify/clarity.go`, `src/pkg/github/clarity_gate_resume.go`) | | `stage/017-possible-existing` from the prior-art gate | Issues | Scheduler kick assembly (`runs.triage.prior_art`) | With the gate on (default on), an unclaimed feature / RFC / epic issue whose key terms match an existing knowledge bead, setting, merged PR, closed issue, doc or code identifier at `runs.triage.prior_art.threshold` (default 70) gets one `` comment quoting the findings and the `stage/017-possible-existing` label instead of a claim; hive-filed issues get a `` note and are never parked ([#13575](https://github.com/hivecommons/hive/issues/13575)). | Hard suppress | Hive | Before kicks are built | The author or a write+ commenter replies `/hive decision proceed — ` (label lifted, a *Scope vs existing* section appended to the body, re-derives 010) or `/hive decision exists` (closed `not_planned` with `already-exists`); a plain reply lifts the label too. A clanker-filed park with no reply is closed `already-exists` after `runs.triage.prior_art.bot_close_ttl` (default 72h); reopen to continue. A 017 a person added is never lifted by the sweep | `runs.triage.prior_art` (`src/pkg/priorart`, `src/pkg/scheduler/prior_art_gate.go`, `src/pkg/github/prior_art_gate_resume.go`) | @@ -298,9 +298,9 @@ An open issue whose GitHub dependency list names an open blocker is enumerated w The issue waits on an unmerged PR (or another outside blocker): the review backlog files a finding `blocked` when its evidence file exists only on the reviewed PR (absent on the base branch), and `hive-open-issue comment --blocked-on-pr ` parks an existing one; both write ``. A `blocked` issue is filtered (reason `blocked on owner/repo#N`), derives no stage label, is refused by every automated claim producer (`blocked: owner/repo#N`) including the contributor relay, and never carries `help wanted` ([#13093](https://github.com/hivecommons/hive/issues/13093)). -When a blocked filing folds into an already-open twin, the twin's own state governs: `blocked` is not applied to it, because the folded body (and its marker) is discarded and the twin's earlier evidence stands on its own; the blocked sweep also lifts a hive-applied `blocked` that has no marker, no deadline and no ops-tracking marker, leaving a human-applied one alone ([#13364](https://github.com/hivecommons/hive/issues/13364)). With no blocked-on marker, a body deadline `` files it `blocked until ` and the activity monitor's blocked chip reads `re-check at ` ([#13310](https://github.com/hivecommons/hive/issues/13310)). +When a blocked filing folds into an already-open twin, the twin's own state governs: `blocked` is not applied to it, because the folded body (and its marker) is discarded and the twin's earlier evidence stands on its own; the blocked sweep also lifts a hive-applied `blocked` that has no marker, no deadline and no ops-tracking marker on a review-backlog item, leaving a human-applied one alone ([#13364](https://github.com/hivecommons/hive/issues/13364)). Any other hive-applied marker-less `blocked` (a contributor relay's verdict that named no issue or PR) becomes a `needs-human` ask, with one note naming the two ways out: name the dependency, or remove `needs-human` to re-queue it. A verdict with no reason at all is not blocked: the hub books it idle and releases the label. With no blocked-on marker, a body deadline `` files it `blocked until ` and the activity monitor's blocked chip reads `re-check at ` ([#13310](https://github.com/hivecommons/hive/issues/13310)). -With the marker, the activity monitor's pill reads `blocked on #N`, links the PR and carries its cached state (`blocked_on_pr` in `/api/stage-tracker`), and the hive's own removal of the label re-reads the issue live rather than waiting for the next enumeration ([#14952](https://github.com/hivecommons/hive/issues/14952)). It is also always skipped by contributor admission and shown in the default waiting band. +With the marker (in the body, or in a comment the blocked sweep has read), the band signal reads `blocked on owner/repo#N — lifted when it merges or closes` instead of `the label records no reason`, the activity monitor's pill reads `blocked on #N`, links the PR and carries its cached state (`blocked_on_pr` in `/api/stage-tracker`), and the hive's own removal of the label re-reads the issue live rather than waiting for the next enumeration ([#14952](https://github.com/hivecommons/hive/issues/14952)). It is also always skipped by contributor admission and shown in the default waiting band. **Who applies it:** Hive (reserved for agents; relay only). diff --git a/src/pkg/dashboard/bands.go b/src/pkg/dashboard/bands.go index d58383c402..81fc2aeb80 100644 --- a/src/pkg/dashboard/bands.go +++ b/src/pkg/dashboard/bands.go @@ -143,6 +143,25 @@ func uniqueLabels(labels, fallback []string) []string { return out } +// blockedNoReasonSignal is the band signal for `blocked` with nothing that +// names the blocker; blockedReasonSignal replaces it when the row's reason +// does (a blocked-on marker, or a recheck deadline). +const blockedNoReasonSignal = "labelled blocked — the label records no reason; see the issue" + +// blockedReasonSignal names what a blocked row waits on from its enumeration +// reason ("blocked on owner/repo#N", "blocked until "); "" when the reason +// is the bare label. projectbluefin/finpilot#624 and #390 carried markers and +// still read "records no reason". +func blockedReasonSignal(reason string) string { + if repo, pr, ok := github.ParseBlockedOnReason(reason); ok { + return fmt.Sprintf("blocked on %s#%d — lifted when it merges or closes", repo, pr) + } + if rest, ok := strings.CutPrefix(strings.TrimSpace(reason), "blocked until "); ok && rest != "" { + return "blocked until " + rest + " — re-checked then" + } + return "" +} + func IssueBand(issue github.Issue, held bool, cfg config.DashboardIssueBandsConfig, now time.Time, selfAuthorizationHoldActive ...func(string) bool) IssueBandInfo { norm := normalizeIssueBandsConfig(cfg) labels := labelSet(issue.Labels) @@ -177,7 +196,7 @@ func IssueBand(issue github.Issue, held bool, cfg config.DashboardIssueBandsConf if open := slices.Compact(issue.OpenBlockers()); len(open) > 0 { signals = append(signals, Signal{Glyph: "⛔", Label: "blocked by " + strings.Join(open, ", ")}) } else if labels["blocked"] { - signals = append(signals, Signal{Glyph: "⛔", Label: "labelled blocked — the label records no reason; see the issue"}) + signals = append(signals, Signal{Glyph: "⛔", Label: blockedNoReasonSignal}) } if labelsNeedDecision(labels) { signals = append(signals, Signal{Glyph: "❓", Label: "needs decision"}) diff --git a/src/pkg/dashboard/blocked_marker_signal_test.go b/src/pkg/dashboard/blocked_marker_signal_test.go new file mode 100644 index 0000000000..4201f2fcf0 --- /dev/null +++ b/src/pkg/dashboard/blocked_marker_signal_test.go @@ -0,0 +1,50 @@ +package dashboard + +import ( + "testing" + "time" + + "github.com/hivecommons/hive/pkg/config" + "github.com/hivecommons/hive/pkg/github" +) + +// projectbluefin/finpilot#624 (the hive's own `pr=projectbluefin/actions#697` +// comment marker) and #390 (a maintainer's) still read "labelled blocked — +// the label records no reason". The row's enumeration reason names the +// blocker; the band signal now says it. +func TestBlockedRowSignalNamesMarker(t *testing.T) { + now := time.Date(2026, 11, 5, 22, 0, 0, 0, time.UTC) + cfg := config.DashboardIssueBandsConfig{} + for _, tc := range []struct { + reason string + want string + }{ + {reason: "blocked on projectbluefin/actions#697", want: "blocked on projectbluefin/actions#697 — lifted when it merges or closes"}, + {reason: "blocked until 2026-11-07T00:00:00Z", want: "blocked until 2026-11-07T00:00:00Z — re-checked then"}, + {reason: "blocked", want: blockedNoReasonSignal}, + {reason: "", want: blockedNoReasonSignal}, + } { + row := github.RepoWorkIssue{Repo: "projectbluefin/finpilot", Number: 624, Labels: []string{"blocked", "triage/accepted"}, Bucket: "filtered", Reason: tc.reason} + info := nonActionableIssueInfo(row, "finpilot", cfg, now, nil) + got := blockedSignals11716(info) + if len(got) != 1 || got[0] != tc.want { + t.Errorf("reason %q: blocked signals = %q, want [%q]", tc.reason, got, tc.want) + } + } +} + +func TestBlockedReasonSignal(t *testing.T) { + for reason, want := range map[string]string{ + "blocked on o/r#5": "blocked on o/r#5 — lifted when it merges or closes", + "blocked": "", + "hold label": "", + "blocked until ": "", + "blocked on o/r#notanum": "", + " blocked on o/r#12 ": "blocked on o/r#12 — lifted when it merges or closes", + "blocked until tomorrow": "blocked until tomorrow — re-checked then", + } { + if got := blockedReasonSignal(reason); got != want { + t.Errorf("blockedReasonSignal(%q) = %q, want %q", reason, got, want) + } + } +} diff --git a/src/pkg/dashboard/contribute_blocked_tooling.go b/src/pkg/dashboard/contribute_blocked_tooling.go index 7eff98cae7..93a78ec6ea 100644 --- a/src/pkg/dashboard/contribute_blocked_tooling.go +++ b/src/pkg/dashboard/contribute_blocked_tooling.go @@ -6,6 +6,7 @@ import ( "regexp" "strings" "time" + "unicode" ghpkg "github.com/hivecommons/hive/pkg/github" ) @@ -64,25 +65,68 @@ func isBlockedVerdictToolingFailure(reason string) bool { return blockedVerdictToolingFailurePattern.MatchString(reason) } -// reclassifyToolingBlockedVerdict demotes a blocked verdict whose reason is a -// contributor-side tooling failure to idle. The second return reports whether -// it did so; every other verdict passes through unchanged. +// reasonlessBlockedReleaseMarker tags the release comment for a blocked +// verdict that gave no reason at all. +const reasonlessBlockedReleaseMarker = "" + +// blockedVerdictFooterLineRE matches the lines a relay appends to every +// comment (`---`, the 🐝 Hive Agent footer): they say nothing about what +// the issue waits on. +var blockedVerdictCommentRE = regexp.MustCompile(`(?s)`) + +var blockedVerdictFooterLineRE = regexp.MustCompile(`(?i)^\s*(?:-{3,}|.*🐝.*|.*\*\*hive agent\*\*.*)\s*$`) + +// isBlockedVerdictReasonless reports whether a blocked verdict's reason says +// nothing: empty, or only HTML comments, footer lines and punctuation. +// projectbluefin/utah#1002 was labelled `blocked` 30 seconds after a relay +// comment that was the footer alone; nothing could say what it waited on. +func isBlockedVerdictReasonless(reason string) bool { + reason = blockedVerdictCommentRE.ReplaceAllString(reason, " ") + for _, line := range strings.Split(reason, "\n") { + if blockedVerdictFooterLineRE.MatchString(line) { + continue + } + for _, r := range line { + if unicode.IsLetter(r) || unicode.IsDigit(r) { + return false + } + } + } + return true +} + +// reclassifyToolingBlockedVerdict demotes to idle a blocked verdict whose +// reason is a contributor-side tooling failure, or that gives no reason at +// all. The second return reports whether it did so; every other verdict +// passes through unchanged. func reclassifyToolingBlockedVerdict(verdict, reason string) (string, bool) { - if verdict != completionVerdictBlocked || !isBlockedVerdictToolingFailure(reason) { + if verdict != completionVerdictBlocked || (!isBlockedVerdictToolingFailure(reason) && !isBlockedVerdictReasonless(reason)) { return verdict, false } return completionVerdictIdle, true } +// blockedReleaseMarker is the release comment's marker for reason. +func blockedReleaseMarker(reason string) string { + if isBlockedVerdictReasonless(reason) { + return reasonlessBlockedReleaseMarker + } + return toolingBlockedReleaseMarker +} + // toolingBlockedReleaseComment is the one comment the hub leaves when it lifts // a tooling-failure `blocked` label. The marker makes the post idempotent. func toolingBlockedReleaseComment(reporter, reason string) string { reporter = strings.TrimSpace(reporter) - reason = sanitizeReportedReason(reason) who := "a contributor's agent" if reporter != "" { who = "@" + reporter + "'s agent" } + if isBlockedVerdictReasonless(reason) { + return fmt.Sprintf("%s\nHive: %s reported this issue blocked but gave no reason, so nothing names what it would wait on. The `%s` label it applied has been removed and the issue stays actionable for other contributors.", + reasonlessBlockedReleaseMarker, who, blockedWorkflowLabel) + } + reason = sanitizeReportedReason(reason) body := fmt.Sprintf("%s\nHive: %s reported this issue blocked, but the reason describes the contributor's own tooling rather than an external dependency, so the `%s` label it applied has been removed and the issue stays actionable for other contributors. Reported reason: %s", toolingBlockedReleaseMarker, who, blockedWorkflowLabel, reason) if reason == "" { @@ -124,7 +168,7 @@ func (h *ContributeWSHub) releaseToolingBlockedLabel(ctx context.Context, repo s if err := client.RemoveLabel(ctx, repo, number, blockedWorkflowLabel); err != nil { return err } - posted, err := client.IssueCommentsContain(ctx, repo, number, toolingBlockedReleaseMarker) + posted, err := client.IssueCommentsContain(ctx, repo, number, blockedReleaseMarker(reason)) if err != nil { return err } diff --git a/src/pkg/dashboard/contribute_blocked_tooling_test.go b/src/pkg/dashboard/contribute_blocked_tooling_test.go index 23f4e725a3..1497787b17 100644 --- a/src/pkg/dashboard/contribute_blocked_tooling_test.go +++ b/src/pkg/dashboard/contribute_blocked_tooling_test.go @@ -49,7 +49,6 @@ func TestBlockedVerdictToolingFailure_Classifier(t *testing.T) { "waiting on projectbluefin/utah-packages to publish a factory image with the recipes", "the upstream library has not released the API this needs", "depends on hivecommons/hub#42 landing first", - "", } for _, reason := range external { if isBlockedVerdictToolingFailure(reason) { @@ -69,7 +68,7 @@ func TestBlockedVerdictToolingFailure_Classifier(t *testing.T) { } func TestBlockedVerdictToolingFailure_ReleaseCommentIsMarkedAndBounded(t *testing.T) { - long := strings.Repeat("§", noWorkReasonMaxLen*2) + long := "push rejected: " + strings.Repeat("§", noWorkReasonMaxLen*2) body := toolingBlockedReleaseComment("mrbobbytables", long) if !strings.HasPrefix(body, toolingBlockedReleaseMarker) { t.Fatalf("release comment must start with the marker, got %q", body[:80]) @@ -86,6 +85,41 @@ func TestBlockedVerdictToolingFailure_ReleaseCommentIsMarkedAndBounded(t *testin } } +// projectbluefin/utah#1002 was labelled `blocked` 30 seconds after a relay +// comment that was only the footer. A blocked verdict that says nothing is +// booked idle and its label released, like a tooling failure. +func TestBlockedVerdictReasonlessIsReleased(t *testing.T) { + for _, reason := range []string{ + "", + " \n\t", + "---\n🐝 **Hive Agent**: `contributor` | **SHA:** `aa24e6f`", + "\n---", + "…", + } { + if !isBlockedVerdictReasonless(reason) { + t.Errorf("isBlockedVerdictReasonless(%q) = false, want true", reason) + } + if v, ok := reclassifyToolingBlockedVerdict(completionVerdictBlocked, reason); !ok || v != completionVerdictIdle { + t.Errorf("reasonless blocked verdict %q: got (%q, %v), want idle", reason, v, ok) + } + if got := blockedReleaseMarker(reason); got != reasonlessBlockedReleaseMarker { + t.Errorf("marker for %q = %q", reason, got) + } + } + for _, reason := range []string{"waiting on #450", "#450", "---\nblocked until the factory publishes\n🐝 **Hive Agent**"} { + if isBlockedVerdictReasonless(reason) { + t.Errorf("isBlockedVerdictReasonless(%q) = true, want false", reason) + } + } + body := toolingBlockedReleaseComment("kylerankin", "---\n🐝 **Hive Agent**") + if !strings.HasPrefix(body, reasonlessBlockedReleaseMarker) || !strings.Contains(body, "gave no reason") || !strings.Contains(body, "@kylerankin") || strings.Contains(body, "Reported reason") { + t.Fatalf("reasonless release comment = %q", body) + } + if blockedReleaseMarker(toolingBlockedReason) != toolingBlockedReleaseMarker { + t.Fatal("a tooling reason keeps the tooling marker") + } +} + // toolingReleaseFixture records what the hub asked the forge to do. type toolingReleaseFixture struct { mu sync.Mutex diff --git a/src/pkg/dashboard/contribute_ws.go b/src/pkg/dashboard/contribute_ws.go index db61d08cfc..4dd761d43f 100644 --- a/src/pkg/dashboard/contribute_ws.go +++ b/src/pkg/dashboard/contribute_ws.go @@ -4498,7 +4498,7 @@ func (s *wsSession) handleTaskComplete(msg WSMessage) { // applied so the fleet's workflow gate does not park it until a // human notices (hivecommons/hive#11775, #11776). if downgraded, ok := reclassifyToolingBlockedVerdict(verdict, verdictReason); ok { - h.logger.Warn("[contribute-ws] blocked verdict reclassified: reason describes contributor tooling, not an external dependency", + h.logger.Warn("[contribute-ws] blocked verdict reclassified: reason is the contributor's own tooling or says nothing, not an external dependency", "username", s.contributor.profile.GitHubUsername, "task", msg.TaskID, "verdict_reason", verdictReason) diff --git a/src/pkg/dashboard/overview_ownership.go b/src/pkg/dashboard/overview_ownership.go index 0dabf8699d..a89faba9f2 100644 --- a/src/pkg/dashboard/overview_ownership.go +++ b/src/pkg/dashboard/overview_ownership.go @@ -123,6 +123,13 @@ func nonActionableIssueInfo(item github.RepoWorkIssue, repoName string, cfg conf HumanAcknowledged: item.HumanAcknowledged, }, false, cfg, now, selfAuthorizationHoldActive) info.Band = nonActionableIssueBand(item) + if named := blockedReasonSignal(item.Reason); named != "" { + for i := range info.Signals { + if info.Signals[i].Label == blockedNoReasonSignal { + info.Signals[i].Label = named + } + } + } if info.Band != "" && info.Chip == "" { info.Chip = issueLabelChip(labelSet([]string{item.Reason})) } diff --git a/src/pkg/github/client.go b/src/pkg/github/client.go index 8a87f08e12..a9ca9d7517 100644 --- a/src/pkg/github/client.go +++ b/src/pkg/github/client.go @@ -2077,7 +2077,7 @@ func (c *Client) fetchIssues(ctx context.Context, repo string, now time.Time, re if hasBlockedLabel(labels) { breakdown.Filtered++ breakdown.Blocked++ - row := c.workIssue(repo, issue, labels, "filtered", blockedFilterReason(issue.GetBody())) + row := c.workIssue(repo, issue, labels, "filtered", blockedFilterReasonFor(repo, issue.GetNumber(), issue.GetBody())) setBlockedRowFacts(&row, issue.GetBody(), blockedCounts[issue.GetNumber()]) details = append(details, row) continue diff --git a/src/pkg/github/issue_blocked.go b/src/pkg/github/issue_blocked.go index 9e72e87870..29fd6a07f4 100644 --- a/src/pkg/github/issue_blocked.go +++ b/src/pkg/github/issue_blocked.go @@ -38,10 +38,12 @@ import ( "sort" "strconv" "strings" + "sync" "time" gh "github.com/google/go-github/v72/github" "github.com/hivecommons/hive/pkg/gfi" + "github.com/hivecommons/hive/pkg/writeback" ) // BlockedLabel is the workflow label that parks an issue on an unmerged PR @@ -313,7 +315,10 @@ type BlockedIssueResult struct { // SoakTriaged counts ops-tracking issues that got soak evidence. SoakTriaged int Retargeted int - Errors int + // AskedHuman counts marker-less hive-applied blocks turned into a + // needs-human ask (blockedMarkerlessAsk). + AskedHuman int + Errors int } // blockedIssueTarget is one blocked issue the sweep looks at. @@ -445,6 +450,7 @@ func (c *Client) reconcileBlockedTargets(ctx context.Context, targets []blockedI scanned = err == nil if scan.ok { prRepo, prNumber, ok = scan.prRepo, scan.pr, scan.ok + noteBlockedOnSeen(t.repo, t.number, scan.prRepo, scan.pr) } if !ok && !t.recheckAfter.IsZero() && !now.Before(t.recheckAfter) { if t.opsTracking && isRecheckSoakRepo(t.repo) { @@ -468,6 +474,10 @@ func (c *Client) reconcileBlockedTargets(ctx context.Context, targets []blockedI if liftBlockedMarkerless(ctx, c, t, &res, logger) { continue } + if askHumanBlockedMarkerless(ctx, c, t, &res, logger) { + stripBlockedHelpWanted(ctx, c, t, &res, logger) + continue + } } stripBlockedHelpWanted(ctx, c, t, &res, logger) continue @@ -620,6 +630,108 @@ func liftBlockedMarkerless(ctx context.Context, client *Client, t blockedIssueTa // refuses stays out of the agent queue. const blockedMarkerlessNote = blockedUnblockedMarker + "\nUnblocked: the `blocked` label was applied by the hive without a blocked-on marker, so nothing could lift it; re-triaging." +// askHumanBlockedMarkerless turns a `blocked` the hive applied with nothing +// naming what the issue waits on into a needs-human ask. A contributor +// relay's blocked verdict is applied with a hub-minted task token (so the +// label's actor is the App bot) and carries no marker when the verdict named +// no issue or PR (#15023 records one when it does). Lifting such a block put +// the issue back in the queue and the next relay re-blocked it, daily +// (projectbluefin/utah#771: 19 label events in 11 days); leaving it made the +// issue invisible, "labelled blocked — the label records no reason" in no +// inbox (projectbluefin/testsuite#908, projectbluefin/utah#1002, blocked 30s +// after a footer-only relay comment). needs-human keeps every agent off it +// and puts it in the maintainer inbox with the question. Only a hive-applied +// label with no open native "blocked by" link is converted; a person's +// marker-less block is theirs. Reports whether the issue was converted. +func askHumanBlockedMarkerless(ctx context.Context, client *Client, t blockedIssueTarget, res *BlockedIssueResult, logger *slog.Logger) bool { + if t.reviewBacklog || t.openBlockedBy > 0 { + return false + } + actor, found, err := client.blockedLabelActor(ctx, t.repo, t.number) + if err != nil { + res.Errors++ + logger.Warn("blocked sweep: timeline lookup failed; marker-less block left alone", "repo", t.repo, "issue", t.number, "error", err) + return false + } + if !found || (!client.isOwnBotLogin(actor) && !client.IsHiveAuthorLogin(actor)) { + return false + } + item, err := client.WritebackItemForNumber(ctx, t.repo, t.number) + if err != nil { + res.Errors++ + logger.Warn("blocked sweep: item lookup failed; marker-less block left alone", "repo", t.repo, "issue", t.number, "error", err) + return false + } + owner, name := client.splitRepo(t.repo) + if d := client.WritebackAllowed(owner+"/"+name, item, writeback.KindGateComment, blockedMarkerlessAskNote); !d.Allowed { + // The burst hold lets a couple of asks per repo through per sweep, + // and a failed write's retry is a duplicate for same_item_ttl; both + // clear on a later sweep. Say so rather than fall through silently. + logger.Info("blocked sweep: needs-human ask held by writeback gate", "repo", t.repo, "issue", t.number, "reason", d.Reason, "detail", d.Detail) + return false + } + if !issueHasLabel(t.labels, issueNeedsHumanLabel) { + if err := client.AddLabels(ctx, t.repo, t.number, []string{issueNeedsHumanLabel}); err != nil { // writeback:gated + res.Errors++ + logger.Warn("blocked sweep: needs-human not added; marker-less block left alone", "repo", t.repo, "issue", t.number, "error", err) + return false + } + } + if err := client.unblockIssue(ctx, t.repo, t.number); err != nil { + res.Errors++ + logger.Warn("blocked sweep: unblock failed", "repo", t.repo, "issue", t.number, "error", err) + return false + } + client.postUnblockedNote(ctx, t.repo, t.number, blockedMarkerlessAskNote, logger) + res.AskedHuman++ + logger.Info("blocked sweep: marker-less hive-applied block turned into a needs-human ask", "repo", t.repo, "issue", t.number, "actor", actor) + return true +} + +// blockedMarkerlessAskNote is the note posted when a marker-less block +// becomes a needs-human ask. It says what was missing and the two ways out. +const blockedMarkerlessAskNote = blockedUnblockedMarker + "\n" + + "Needs a maintainer: a contributor's agent reported this issue blocked but named no issue or pull request it waits on, so the `blocked` label could never be lifted and the issue showed in no inbox. " + + "Hive replaced `blocked` with `needs-human`. Either name the dependency (a GitHub \"blocked by\" link, or re-add `blocked` with a `` comment; Hive lifts it when that closes) or remove `needs-human` to put the issue back in the queue." + +// blockedOnSeen remembers the blocker the sweep read from an issue's newest +// blocked-on comment marker. The enumeration reads only the issue body, so a +// marker the hive or a maintainer left in a comment (projectbluefin/finpilot#624, +// #390) was invisible to the row's reason and the band. +var blockedOnSeen = struct { + sync.Mutex + m map[string]string +}{m: map[string]string{}} + +func blockedOnSeenKey(repo string, number int) string { + return strings.ToLower(strings.TrimSpace(repo)) + "#" + strconv.Itoa(number) +} + +func noteBlockedOnSeen(repo string, number int, prRepo string, pr int) { + blockedOnSeen.Lock() + defer blockedOnSeen.Unlock() + blockedOnSeen.m[blockedOnSeenKey(repo, number)] = prRepo + "#" + strconv.Itoa(pr) +} + +func forgetBlockedOnSeen(repo string, number int) { + blockedOnSeen.Lock() + defer blockedOnSeen.Unlock() + delete(blockedOnSeen.m, blockedOnSeenKey(repo, number)) +} + +// blockedFilterReasonFor is blockedFilterReason with the blocker the sweep +// last read from the issue's comments preferred over the body's marker, the +// same precedence the sweep lifts by. +func blockedFilterReasonFor(repo string, number int, body string) string { + blockedOnSeen.Lock() + seen := blockedOnSeen.m[blockedOnSeenKey(repo, number)] + blockedOnSeen.Unlock() + if seen != "" { + return blockedFilterReasonPrefix + " on " + seen + } + return blockedFilterReason(body) +} + // blockedPRSettledNote is the note posted when the PR a blocked issue // waited on (pr, "owner/repo#N") has merged or closed. func blockedPRSettledNote(pr, admission string) string { diff --git a/src/pkg/github/issue_blocked_test.go b/src/pkg/github/issue_blocked_test.go index f02de82e5f..f7e42bb923 100644 --- a/src/pkg/github/issue_blocked_test.go +++ b/src/pkg/github/issue_blocked_test.go @@ -1,13 +1,16 @@ package github import ( + "bytes" "context" "encoding/json" "fmt" "io" + "log/slog" "net/http" "net/http/httptest" "os" + "strconv" "strings" "sync" "testing" @@ -16,6 +19,7 @@ import ( "github.com/hivecommons/hive/pkg/config" "github.com/hivecommons/hive/pkg/gfi" "github.com/hivecommons/hive/pkg/stagelabels" + "github.com/hivecommons/hive/pkg/writeback" ) func TestBlockedOnMarkerRoundTrip(t *testing.T) { @@ -266,6 +270,8 @@ func TestReconcileBlockedIssues(t *testing.T) { _, _ = io.WriteString(w, `[{"event":"labeled","created_at":"2026-10-20T10:05:00Z","label":{"name":"blocked"},"actor":{"login":"`+testBot+`","type":"Bot"}}]`) case r.Method == "DELETE" && strings.HasPrefix(r.URL.Path, "/repos/o/r/issues/"): _, _ = io.WriteString(w, `[]`) + case r.Method == "POST" && r.URL.Path == "/repos/o/r/issues/80/labels": + _, _ = io.WriteString(w, `[{"name":"needs-human"}]`) case r.Method == "POST" && strings.HasSuffix(r.URL.Path, "/comments"): var body struct { Body string `json:"body"` @@ -297,10 +303,10 @@ func TestReconcileBlockedIssues(t *testing.T) { // review-backlog item (a blocked filing folded into an open twin, // hivecommons/hive#13364) is a defect: lifted. {Repo: "o/r", Number: 70, Labels: []string{"blocked"}, Bucket: workBucketFiltered, Reason: "blocked", ReviewBacklog: true}, - // A contributor relay's blocked verdict: the task token makes the - // labeled actor the hive's own bot, but it is not a review-backlog - // item, so it stays for a human (hivecommons/hive#7924) and only - // loses `help wanted`. + // A contributor relay's blocked verdict that named nothing: the + // task token makes the labeled actor the hive's own bot. It is + // not lifted (the next relay would re-block it) but turned into + // a needs-human ask, and loses `help wanted`. {Repo: "o/r", Number: 80, Labels: []string{"blocked", "help wanted"}, Bucket: workBucketFiltered, Reason: "blocked"}, // A review-backlog item GitHub still reports an open "blocked // by" dependency on (#9839) stays blocked. @@ -308,7 +314,7 @@ func TestReconcileBlockedIssues(t *testing.T) { }}, }} res := ReconcileBlockedIssues(context.Background(), c, result, nil) - if res.Items != 8 || res.Unblocked != 3 || res.Stripped != 3 || res.Errors != 1 { + if res.Items != 8 || res.Unblocked != 3 || res.AskedHuman != 1 || res.Stripped != 3 || res.Errors != 1 { t.Fatalf("result = %+v", res) } mu.Lock() @@ -327,7 +333,12 @@ func TestReconcileBlockedIssues(t *testing.T) { "DELETE /repos/o/r/issues/70/labels/blocked", "POST /repos/o/r/issues/70/comments", "GET /repos/o/r/issues/80/comments", + "GET /repos/o/r/issues/80/timeline", + "POST /repos/o/r/issues/80/labels", + "DELETE /repos/o/r/issues/80/labels/blocked", + "POST /repos/o/r/issues/80/comments", "DELETE /repos/o/r/issues/80/labels/help wanted", + "GET /repos/o/r/issues/60/timeline", "GET /repos/o/r/issues/90/comments", } { if !strings.Contains(joined, want) { @@ -340,12 +351,9 @@ func TestReconcileBlockedIssues(t *testing.T) { "/repos/o/r/issues/50", "DELETE /repos/o/r/issues/60/labels/blocked", "GET /repos/o/r/issues/30/timeline", - // Neither a non-backlog issue nor an open native blocker spends a - // timeline read: the lift is ruled out before it. - "GET /repos/o/r/issues/60/timeline", - "GET /repos/o/r/issues/80/timeline", - "DELETE /repos/o/r/issues/80/labels/blocked", - "POST /repos/o/r/issues/80/comments", + // A person's marker-less block is read (to learn who applied it) + // but never converted; an open native blocker spends no read. + "POST /repos/o/r/issues/60/labels", "GET /repos/o/r/issues/90/timeline", "DELETE /repos/o/r/issues/90/labels/blocked", "POST /repos/o/r/issues/90/comments", @@ -506,6 +514,19 @@ func TestEnumerateActionableRecordsBlockedRecheckAfter(t *testing.T) { if r := rows[3]; r.Bucket != workBucketFiltered || r.Reason != "blocked" || !r.ReviewBacklog || r.OpenBlockedBy != 2 { t.Fatalf("backlog row = %+v", r) } + // A blocked-on marker the sweep read from #2's comments names the + // row's blocker on the next enumeration (projectbluefin/finpilot#624). + noteBlockedOnSeen(repo, 2, "other/actions", 697) + t.Cleanup(func() { forgetBlockedOnSeen(repo, 2) }) + result, err = c.EnumerateActionable(context.Background()) + if err != nil { + t.Fatalf("EnumerateActionable: %v", err) + } + for _, row := range result.WorkDetailsByRepo[repo].Issues { + if row.Number == 2 && row.Reason != "blocked on other/actions#697" { + t.Fatalf("row reason after a comment marker = %q", row.Reason) + } + } } // The sweep lifts `blocked` from a row whose recheck-after deadline has @@ -941,41 +962,63 @@ func TestReconcileBlockedIssuesCommentMarkerOverridesBody(t *testing.T) { // A contributor relay's marker-less `blocked` carries the hive's own bot as // the labeled actor (the hub-minted task token). Lifting it put the issue -// back in the ready band, the next agent re-hit the blocker and the relay -// re-applied the label, every day. The sweep keeps it across passes; a -// review-backlog item blocked without a marker (hivecommons/hive#13364) is -// still lifted once, and one GitHub reports an open "blocked by" on stays. -func TestSweepBlockedIssuesKeepsRelayMarkerlessBlock(t *testing.T) { +// back in the ready band and the next relay re-blocked it, daily +// (projectbluefin/utah#771); keeping it hid the issue from every inbox +// (projectbluefin/testsuite#908). The sweep turns it into a needs-human ask, +// once. Decision table: +// +// #70 review-backlog, hive-applied, no marker → lifted (hivecommons/hive#13364) +// #80 relay verdict, hive-applied, no marker → needs-human ask +// #85 a person applied it, no marker → left alone +// #90 open native "blocked by" link (backlog) → left alone +// #92 open native "blocked by" link (relay) → left alone +// #95 blocked-on marker in a comment (open PR) → left alone; the row names the PR +func TestSweepBlockedIssuesAsksHumanOnRelayMarkerlessBlock(t *testing.T) { var mu sync.Mutex var calls []string - lifted := false + gone := map[int]bool{} backlogBody := "Filed from an out-of-scope finding in the Hive review of PR #9.\n\n" + reviewBacklogFooter + "\n" srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") mu.Lock() calls = append(calls, r.Method+" "+r.URL.Path) - done := lifted mu.Unlock() switch { case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues" && strings.Contains(r.URL.RawQuery, "labels=blocked"): items := []map[string]any{ - {"number": 80, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": "Upgrade the client once the upstream API ships."}, + {"number": 85, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": "Waiting on the vendor."}, {"number": 90, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": backlogBody, "issue_dependencies_summary": map[string]any{"blocked_by": 1, "total_blocked_by": 1}}, + {"number": 95, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": "Needs the shared workflow fix."}, + {"number": 92, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": "Waits on the upstream issue.", "issue_dependencies_summary": map[string]any{"blocked_by": 1, "total_blocked_by": 1}}, } - if !done { + mu.Lock() + if !gone[70] { items = append(items, map[string]any{"number": 70, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": backlogBody}) } + if !gone[80] { + items = append(items, map[string]any{"number": 80, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": "Upgrade the client once the upstream API ships."}) + } + mu.Unlock() _ = json.NewEncoder(w).Encode(items) + case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues/95/comments": + _, _ = io.WriteString(w, `[{"id":3,"body":"`+BlockedOnMarker("other/actions", 697)+`\nblocked on the shared fix"}]`) + case r.Method == "GET" && r.URL.Path == "/repos/other/actions/pulls/697": + _, _ = io.WriteString(w, `{"number":697,"state":"open"}`) case r.Method == "GET" && strings.HasSuffix(r.URL.Path, "/comments"): - _, _ = io.WriteString(w, `[{"id":1,"body":"Blocked: the upstream API this needs is not released yet."}]`) + _, _ = io.WriteString(w, `[{"id":1,"body":"---\n🐝 **Hive Agent**: `+"`contributor`"+`"}]`) + case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues/85/timeline": + _, _ = io.WriteString(w, `[{"event":"labeled","created_at":"2026-10-27T20:38:49Z","label":{"name":"blocked"},"actor":{"login":"castrojo","type":"User"}}]`) case r.Method == "GET" && strings.HasSuffix(r.URL.Path, "/timeline"): - _, _ = io.WriteString(w, `[{"event":"labeled","created_at":"2026-10-28T17:14:50Z","label":{"name":"blocked"},"actor":{"login":"`+testBot+`","type":"Bot"}}]`) - case r.Method == "DELETE" && r.URL.Path == "/repos/o/r/issues/70/labels/blocked": + _, _ = io.WriteString(w, `[{"event":"labeled","created_at":"2026-10-29T04:17:25Z","label":{"name":"blocked"},"actor":{"login":"`+testBot+`","type":"Bot"}}]`) + case r.Method == "POST" && r.URL.Path == "/repos/o/r/issues/80/labels": + _, _ = io.WriteString(w, `[{"name":"needs-human"}]`) + case r.Method == "DELETE" && (r.URL.Path == "/repos/o/r/issues/70/labels/blocked" || r.URL.Path == "/repos/o/r/issues/80/labels/blocked"): + n, _ := strconv.Atoi(strings.Split(r.URL.Path, "/")[5]) mu.Lock() - lifted = true + gone[n] = true mu.Unlock() _, _ = io.WriteString(w, `[]`) - case r.Method == "POST" && r.URL.Path == "/repos/o/r/issues/70/comments": + case r.Method == "POST" && (r.URL.Path == "/repos/o/r/issues/70/comments" || r.URL.Path == "/repos/o/r/issues/80/comments"): _, _ = io.WriteString(w, `{"id":9}`) default: w.WriteHeader(http.StatusNotFound) @@ -990,38 +1033,75 @@ func TestSweepBlockedIssuesKeepsRelayMarkerlessBlock(t *testing.T) { if err != nil { t.Fatalf("pass %d: SweepBlockedIssues failed: %v", pass, err) } - wantUnblocked := 0 + want := 0 if pass == 1 { - wantUnblocked = 1 + want = 1 } - if res.Unblocked != wantUnblocked || res.Errors != 0 { - t.Fatalf("pass %d: res = %+v, want Unblocked=%d Errors=0", pass, res, wantUnblocked) + if res.Unblocked != want || res.AskedHuman != want || res.Errors != 0 { + t.Fatalf("pass %d: res = %+v, want Unblocked=%d AskedHuman=%d Errors=0", pass, res, want, want) } } mu.Lock() defer mu.Unlock() joined := strings.Join(calls, "\n") for _, want := range []string{ - "GET /repos/o/r/issues/70/timeline", "DELETE /repos/o/r/issues/70/labels/blocked", - "POST /repos/o/r/issues/70/comments", + "POST /repos/o/r/issues/80/labels", + "DELETE /repos/o/r/issues/80/labels/blocked", + "POST /repos/o/r/issues/80/comments", } { if !strings.Contains(joined, want) { t.Errorf("missing call %q in:\n%s", want, joined) } } + if strings.Index(joined, "POST /repos/o/r/issues/80/labels") > strings.Index(joined, "DELETE /repos/o/r/issues/80/labels/blocked") { + t.Errorf("needs-human must land before blocked comes off, or a failed add leaves the issue in the queue:\n%s", joined) + } for _, never := range []string{ - "DELETE /repos/o/r/issues/80/labels/blocked", - "POST /repos/o/r/issues/80/comments", - "GET /repos/o/r/issues/80/timeline", - "DELETE /repos/o/r/issues/90/labels/blocked", - "POST /repos/o/r/issues/90/comments", - "GET /repos/o/r/issues/90/timeline", + "DELETE /repos/o/r/issues/85/labels/blocked", "POST /repos/o/r/issues/85/labels", + "DELETE /repos/o/r/issues/90/labels/blocked", "POST /repos/o/r/issues/90/labels", "GET /repos/o/r/issues/90/timeline", + "DELETE /repos/o/r/issues/95/labels/blocked", "POST /repos/o/r/issues/95/labels", "GET /repos/o/r/issues/95/timeline", + "DELETE /repos/o/r/issues/92/labels/blocked", "POST /repos/o/r/issues/92/labels", "GET /repos/o/r/issues/92/timeline", } { if strings.Contains(joined, never) { t.Errorf("unexpected call %q in:\n%s", never, joined) } } + if got := blockedFilterReasonFor("o/r", 95, "Needs the shared workflow fix."); got != "blocked on other/actions#697" { + t.Errorf("row reason for a comment marker = %q, want blocked on other/actions#697", got) + } + if got := blockedFilterReasonFor("o/r", 85, "Waiting on the vendor."); got != "blocked" { + t.Errorf("row reason with no marker = %q, want the bare label", got) + } +} + +// The note says what was missing and both ways out. +func TestBlockedMarkerlessAskNote(t *testing.T) { + for _, want := range []string{blockedUnblockedMarker, "named no issue or pull request", "`needs-human`", "hive:blocked-on pr=owner/repo#N", "blocked by"} { + if !strings.Contains(blockedMarkerlessAskNote, want) { + t.Errorf("note lacks %q:\n%s", want, blockedMarkerlessAskNote) + } + } +} + +// unblockIssue forgets the comment marker it remembered. +func TestUnblockForgetsCommentMarker(t *testing.T) { + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + _, _ = io.WriteString(w, `[]`) + })) + defer srv.Close() + c := testClient(t, srv.URL) + noteBlockedOnSeen("o/r", 7, "o/r", 3) + if got := blockedFilterReasonFor("O/R", 7, ""); got != "blocked on o/r#3" { + t.Fatalf("reason = %q", got) + } + if err := c.unblockIssue(context.Background(), "o/r", 7); err != nil { + t.Fatal(err) + } + if got := blockedFilterReasonFor("o/r", 7, ""); got != "blocked" { + t.Fatalf("reason after unblock = %q, want the bare label", got) + } } // Issue 14194: SweepBlockedIssues lists open issues with `blocked` label directly @@ -1065,3 +1145,58 @@ func TestSweepBlockedIssues(t *testing.T) { t.Fatal("blocked label was not removed from issue 10") } } + +// A writeback-gate refusal (a burst hold, a duplicate within same_item_ttl, +// a paused repo) leaves the block as it is for a later sweep and says so in +// the log instead of falling through silently. +func TestSweepBlockedAskHeldByGateLogs(t *testing.T) { + var mu sync.Mutex + var calls []string + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + mu.Lock() + calls = append(calls, r.Method+" "+r.URL.Path) + mu.Unlock() + switch { + case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues" && strings.Contains(r.URL.RawQuery, "labels=blocked"): + _, _ = io.WriteString(w, `[{"number":80,"state":"open","labels":[{"name":"blocked"}],"body":"Upgrade once upstream ships."}]`) + case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues/80": + _, _ = io.WriteString(w, `{"number":80,"state":"open","user":{"login":"`+testBot+`"},"labels":[{"name":"blocked"}]}`) + case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues/80/comments": + _, _ = io.WriteString(w, `[]`) + case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues/80/timeline": + _, _ = io.WriteString(w, `[{"event":"labeled","created_at":"2026-10-29T04:17:25Z","label":{"name":"blocked"},"actor":{"login":"`+testBot+`","type":"Bot"}}]`) + default: + w.WriteHeader(http.StatusNotFound) + _, _ = fmt.Fprintf(w, `{"path":%q}`, r.URL.Path) + } + })) + defer srv.Close() + c := testClient(t, srv.URL) + c.appBotLogin = testBot + var logs bytes.Buffer + c.logger = slog.New(slog.NewTextHandler(&logs, nil)) + c.SetWritebackGate(writeback.New(writeback.Config{}, writeback.Deps{ + RepoPause: func(string) (writeback.RepoPauseInfo, bool) { + return writeback.RepoPauseInfo{By: "owner", Reason: "freeze"}, true + }, + }, "")) + res, err := c.SweepBlockedIssues(context.Background(), BlockedSweepOptions{Repos: []string{"o/r"}}) + if err != nil { + t.Fatalf("SweepBlockedIssues: %v", err) + } + if res.AskedHuman != 0 || res.Unblocked != 0 { + t.Fatalf("res = %+v, want nothing converted while the gate refuses", res) + } + mu.Lock() + joined := strings.Join(calls, "\n") + mu.Unlock() + for _, never := range []string{"POST /repos/o/r/issues/80/labels", "DELETE /repos/o/r/issues/80/labels/blocked", "POST /repos/o/r/issues/80/comments"} { + if strings.Contains(joined, never) { + t.Errorf("unexpected call %q while the gate refuses:\n%s", never, joined) + } + } + if out := logs.String(); !strings.Contains(out, "needs-human ask held by writeback gate") || !strings.Contains(out, "issue=80") { + t.Fatalf("gate refusal not logged:\n%s", out) + } +} diff --git a/src/pkg/github/item_refresh_hook.go b/src/pkg/github/item_refresh_hook.go index 992cbb44fd..316bedbbb4 100644 --- a/src/pkg/github/item_refresh_hook.go +++ b/src/pkg/github/item_refresh_hook.go @@ -50,6 +50,7 @@ func (c *Client) unblockIssue(ctx context.Context, repo string, number int) erro if err := c.RemoveLabel(ctx, repo, number, BlockedLabel); err != nil { return err } + forgetBlockedOnSeen(repo, number) // The row's since-time restarts at the lift (hivecommons/hive#15779). stagelabels.Shared().NoteUnblocked(stagelabels.Key(repo, number), time.Now()) notifyItemRefresh(repo, number, false) diff --git a/src/pkg/github/webhook_item_patch.go b/src/pkg/github/webhook_item_patch.go index e1cde5947f..8fd4335a83 100644 --- a/src/pkg/github/webhook_item_patch.go +++ b/src/pkg/github/webhook_item_patch.go @@ -86,7 +86,7 @@ func (c *Client) classifyWebhookIssue(repo string, issue *gh.Issue, blockedBy in return sidelined("filtered", trackingFilterReason) } if hasBlockedLabel(labels) { - row := c.workIssue(repo, issue, labels, "filtered", blockedFilterReason(issue.GetBody())) + row := c.workIssue(repo, issue, labels, "filtered", blockedFilterReasonFor(repo, issue.GetNumber(), issue.GetBody())) setBlockedRowFacts(&row, issue.GetBody(), blockedBy) return WebhookItemPatch{Bucket: WebhookBucketSidelined, WorkIssue: &row} }