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-one-unblock-notice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- A lifted block gets one "Unblocked" note, and it no longer calls an un-admitted issue actionable. On projectbluefin/website#987 the review-backlog reconciler posted "Unblocked: …#986 merged … This item is actionable now" and, 8 seconds later, the blocked sweep posted "Unblocked: …#986 is no longer open; re-triaging." The issue had no `triage/accepted`, so neither was true. Whichever path runs second now sees the first one's note for the same PR and stays quiet. On an issue `project.issue_filter` does not admit, the note says "Unblocked — waiting for a maintainer to admit it" and names the label that admits it.
8 changes: 7 additions & 1 deletion src/docs/hive-open-issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,13 @@ blocked sweep that follows each stage-label sync lifts the label and posts
one `<!-- hive:unblocked -->` note once the tracked PR is merged or closed,
and strips `help wanted` again should the org workflow re-add it while the
PR is open. The review backlog applies the same parking itself when it files
a finding whose file does not exist on the reviewed PR's base branch.
a finding whose file does not exist on the reviewed PR's base branch. The
review-backlog reconciler and the blocked sweep can both lift the same block;
whichever runs second sees the first one's note for that PR (newer than the
last blocked-on marker) and posts nothing. On an issue `project.issue_filter`
does not admit (for example no `triage/accepted`), the note says
"Unblocked — waiting for a maintainer to admit it" and names the label that
admits it, instead of "actionable now" or "re-triaging".

A posted comment is the agent's **start signal** on that issue only when it
says work is starting. The hub records a 2h agent claim the first time the
Expand Down
2 changes: 1 addition & 1 deletion src/docs/labels-and-control-signals/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ With the marker, the activity monitor's pill reads `blocked on #N`, links the PR

**Checked by:** Enumeration, stage derivation, claim gate, review backlog, blocked sweep. **When:** Review backlog filing; blocked-on comment relay.

**Release or override.** The blocked sweep after each stage-label sync removes it, with one `<!-- hive:unblocked -->` note, once the tracked PR is merged or closed, or once a recheck-after deadline passes (`deadline <t> passed; re-triaging`) unless the body also carries `<!-- hive:ops-tracking -->`. 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 <short-sha>` named in the body), ONE `<!-- hive:recheck-evidence at=<RFC3339> -->` comment is posted, only the checklist lines that evidence proves are ticked, and `<!-- hive:recheck-done -->` 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.
**Release or override.** The blocked sweep after each stage-label sync removes it, with one `<!-- hive:unblocked -->` note (none when the review-backlog reconciler already noted the lift for the same PR; "waiting for a maintainer to admit it" on an issue `project.issue_filter` does not admit), once the tracked PR is merged or closed, or once a recheck-after deadline passes (`deadline <t> passed; re-triaging`) unless the body also carries `<!-- hive:ops-tracking -->`. 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 <short-sha>` named in the body), ONE `<!-- hive:recheck-evidence at=<RFC3339> -->` comment is posted, only the checklist lines that evidence proves are ticked, and `<!-- hive:recheck-done -->` 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.

The hard-suppress reconcile (#12002) can also lift a Hive-applied `blocked` after a referencing PR merges, but only when the newest label event was by the App bot; human-applied or re-applied labels are not lifted. It posts `<!-- hive:hard-suppress-lifted -->`.

Expand Down
91 changes: 88 additions & 3 deletions src/pkg/github/issue_blocked.go
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ func (c *Client) reconcileBlockedTargets(ctx context.Context, targets []blockedI
logger.Warn("blocked sweep: unblock failed", "repo", t.repo, "issue", t.number, "error", err)
continue
}
note := blockedUnblockedMarker + fmt.Sprintf("\nUnblocked: %s#%d (superseding #%d) is no longer open. This issue is actionable again.", prRepo, supersededBy, prNumber)
note := blockedSupersededSettledNote(prRepo, supersededBy, prNumber, c.unblockAdmission(t.labels))
c.postUnblockedNote(ctx, t.repo, t.number, note, logger)
res.Unblocked++
logger.Info("blocked sweep: issue unblocked", "repo", t.repo, "issue", t.number, "pr", prRepo+"#"+strconv.Itoa(supersededBy), "superseded", prNumber)
Expand Down Expand Up @@ -542,7 +542,7 @@ func (c *Client) reconcileBlockedTargets(ctx context.Context, targets []blockedI
logger.Warn("blocked sweep: unblock failed", "repo", t.repo, "issue", t.number, "error", err)
continue
}
note := blockedPRSettledNote(prRepo + "#" + strconv.Itoa(prNumber))
note := blockedPRSettledNote(prRepo+"#"+strconv.Itoa(prNumber), c.unblockAdmission(t.labels))
c.postUnblockedNote(ctx, t.repo, t.number, note, logger)
res.Unblocked++
logger.Info("blocked sweep: issue unblocked", "repo", t.repo, "issue", t.number, "pr", prRepo+"#"+strconv.Itoa(prNumber))
Expand Down Expand Up @@ -622,10 +622,90 @@ const blockedMarkerlessNote = blockedUnblockedMarker + "\nUnblocked: the `blocke

// blockedPRSettledNote is the note posted when the PR a blocked issue
// waited on (pr, "owner/repo#N") has merged or closed.
func blockedPRSettledNote(pr string) string {
func blockedPRSettledNote(pr, admission string) string {
if admission != "" {
return blockedUnblockedMarker + "\nUnblocked: " + pr + " is no longer open. Unblocked — waiting for a maintainer to admit it: " + admission
}
return blockedUnblockedMarker + "\nUnblocked: " + pr + " is no longer open; re-triaging."
}

// blockedSupersededSettledNote is the note posted when the PR that superseded
// an issue's blocker is no longer open either.
func blockedSupersededSettledNote(prRepo string, supersededBy, prNumber int, admission string) string {
lead := blockedUnblockedMarker + fmt.Sprintf("\nUnblocked: %s#%d (superseding #%d) is no longer open.", prRepo, supersededBy, prNumber)
if admission != "" {
return lead + " Unblocked — waiting for a maintainer to admit it: " + admission
}
return lead + " This issue is actionable again."
}

// unblockAdmission is "" when project.issue_filter admits an issue with
// these labels once `blocked` is gone; otherwise the sentence an unblock note
// ends with instead of "actionable": nothing works an un-admitted issue
// until a maintainer admits it (projectbluefin/website#987 had no
// triage/accepted and was told it was actionable).
func (c *Client) unblockAdmission(labels []string) string {
after := make([]string, 0, len(labels))
for _, l := range labels {
if !strings.EqualFold(strings.TrimSpace(l), BlockedLabel) {
after = append(after, l)
}
}
filter := c.getIssueFilter()
if filter.Admits(after) {
return ""
}
var required []string
if notice, ok := filter.(IssueFilterNoticeConfig); ok {
required = notice.RequireLabelsForNotice()
}
const lead = "`project.issue_filter` admits "
switch len(required) {
case 0:
return lead + "only issues carrying one of its required labels, and a maintainer adding one admits this one."
case 1:
return lead + "only issues labelled " + quoteLabels(required) + ", and a maintainer adding it admits this one."
default:
return lead + "only issues carrying one of " + quoteLabels(required) + ", and a maintainer adding one admits this one."
}
}

// unblockNoteRefRE reads the PR an unblock note is about: "Unblocked:
// owner/repo#N …" or "Unblocked: source PR owner/repo#N …".
var unblockNoteRefRE = regexp.MustCompile(`Unblocked: (?:source PR )?([\w.-]+/[\w.-]+)#(\d+)\b`)

// unblockAlreadyNoted reports whether an unblock note about the same PR as
// note is already on the issue, newer than the newest blocked-on marker
// comment: the block on that PR was lifted already, by the other sweep or an
// earlier pass. projectbluefin/website#987 got the review-backlog sweep's
// "merged … actionable now" and, 8s later, the blocked sweep's "no longer
// open; re-triaging" for the same #986. A note naming no PR (deadline,
// marker-less) is never matched here.
func unblockAlreadyNoted(comments []*gh.IssueComment, note string) bool {
m := unblockNoteRefRE.FindStringSubmatch(note)
if m == nil {
return false
}
short := m[1]
if i := strings.LastIndex(short, "/"); i >= 0 {
short = short[i+1:]
}
same := regexp.MustCompile(`(?i)Unblocked: (?:source PR )?(?:[\w.-]+/)?` + regexp.QuoteMeta(short) + `#` + m[2] + `\b`)
for i := len(comments) - 1; i >= 0; i-- {
body := comments[i].GetBody()
if strings.Contains(body, blockedUnblockedMarker) {
if same.MatchString(body) {
return true
}
continue
}
if _, _, ok := ParseBlockedOnMarker(body); ok {
return false
}
}
return false
}

// blockedLabelActor returns the login that most recently applied `blocked`
// to the issue, per its timeline; found is false when no labeled event
// names the label.
Expand Down Expand Up @@ -717,6 +797,11 @@ func (c *Client) postUnblockedNote(ctx context.Context, repo string, number int,
return
}
}
if unblockAlreadyNoted(comments, note) {
logger.Info("blocked sweep: the block on this PR was already lifted with a note; not posting a second", "repo", repo, "issue", number)
c.noteCommentSuppressed()
return
}
// The attention pilot folds dependency progress into the issue's
// status card whatever github.notifications.mode says.
if c.notificationsQuiet() || c.attentionPilot() {
Expand Down
Loading
Loading