From 3f4d44c46a42fabb91203c8b5362bc2f93a500a2 Mon Sep 17 00:00:00 2001 From: Danathar Date: Wed, 28 Oct 2026 13:30:44 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(blocked):=20keep=20a=20relay?= =?UTF-8?q?'s=20marker-less=20blocked=20label=20instead=20of=20lifting=20i?= =?UTF-8?q?t?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A contributor relay applies `blocked` on a blocked verdict with the hub-minted task token, so GitHub records the hive's own App bot as the labeled actor, and it writes no blocked-on marker by design (lifting is a person's, hivecommons/hive#7924, #12376). liftBlockedMarkerless, added for review-backlog twins (#13364), lifted any marker-less block the hive bot applied, so it took every relay verdict for a defect: the issue went back to the ready band, the next agent hit the same blocker and the relay re-applied the label, daily. The marker-less lift now applies only to review-backlog items (body carries reviewBacklogFooter), the one hive path it was written for, and never while GitHub reports an open "blocked by" link (#9839). Both facts come from payloads the enumeration, webhook re-read and blocked sweep already fetch: the row records them, and the sweep's listing now keeps issue_dependencies_summary. Neither costs a timeline read: both are ruled out before it. The pr= marker and recheck-after paths are unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1 Signed-off-by: Danathar --- .../fixed-blocked-keep-relay-blocks.md | 1 + src/docs/labels-and-control-signals.md | 4 +- src/docs/scale-envelope.md | 2 +- src/pkg/github/client.go | 9 +- src/pkg/github/issue_blocked.go | 132 +++++++++++++----- src/pkg/github/issue_blocked_test.go | 129 ++++++++++++++++- src/pkg/github/webhook_item_patch.go | 10 +- src/pkg/github/webhook_item_refresh.go | 2 +- src/pkg/github/webhook_item_refresh_test.go | 32 +++++ 9 files changed, 265 insertions(+), 56 deletions(-) create mode 100644 changelog.d/fixed-blocked-keep-relay-blocks.md diff --git a/changelog.d/fixed-blocked-keep-relay-blocks.md b/changelog.d/fixed-blocked-keep-relay-blocks.md new file mode 100644 index 0000000000..d6c27519d9 --- /dev/null +++ b/changelog.d/fixed-blocked-keep-relay-blocks.md @@ -0,0 +1 @@ +- Blocked sweep: a contributor relay's `blocked` verdict is no longer lifted every few minutes. The relay labels with its hub-minted task token, so GitHub records the hive's own App bot as the actor, and the marker-less lift added for review-backlog twins ([#13364](https://github.com/hivecommons/hive/issues/13364)) took it for a hive defect: the issue went back to the ready band, the next agent hit the same blocker and the relay re-applied the label, daily. The marker-less lift now applies only to review-backlog items (body carries `filed by Hive review backlog`) that GitHub reports no open "blocked by" link on; every other marker-less `blocked` stays for a person to lift (`/hive approve`, [#7924](https://github.com/hivecommons/hive/issues/7924)). diff --git a/src/docs/labels-and-control-signals.md b/src/docs/labels-and-control-signals.md index fb2dcbc2ad..5d55c92279 100644 --- a/src/docs/labels-and-control-signals.md +++ b/src/docs/labels-and-control-signals.md @@ -74,7 +74,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, 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)). | 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)). 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`) | | `needs-human` | Issues | Enumeration, task-list sweep, claim escalation gate and un-park sweep | Issue is filtered, not held: no agent kick or contributor offer; task-list sweep adds it only when a merged PR carries the explicit `Refs #N (needs-human: )` marker (never on a held issue; remainder prose yields `hive/handoff` instead, [#12002](https://github.com/hivecommons/hive/issues/12002)), and the claim escalation gate adds it instead of a third no-progress claim by the same agent (`governor.claims.escalate_after_claims`, [#10527](https://github.com/hivecommons/hive/issues/10527)). The un-park sweep keeps a "What to reply" comment on every parked issue listing the commands. See [Maintainer commands](maintainer-commands.md). | Hard suppress | Hive or human | Enumeration/task-list sweep/kick building | A person removes it, or a maintainer's `/hive approve` / `/hive decision ` when **Hive** added it (`stageengine.DecisionLiftsNeedsHuman`): the un-park sweep reads the label timeline, and when the last `labeled needs-human` actor is one of the hive's accounts the decision is the human input the hive asked for, so the label lifts with `stage/045-needs-decision`, `approved-direction` is added and the stage engine derives `stage/010-actionable` — left in place it re-derived 045 on the next reconcile and the decision was a silent no-op ([#13075](https://github.com/hivecommons/hive/issues/13075), seen on [#12984](https://github.com/hivecommons/hive/issues/12984)). When a person added it, or the timeline cannot say who did, the commands and label-driven approval add `approved-direction` and clear 045 (and the retired spellings, including a pre-045 `stage/085-needs-decision`) but **never** remove `needs-human`: it says a human-held identity, consent or operator step is required, which no decision supplies, so the issue stays derived at `stage/045-needs-decision` and out of the agent queue after the un-park ([#12680](https://github.com/hivecommons/hive/issues/12680), [#12681](https://github.com/hivecommons/hive/issues/12681)). Agents may ADD it through the relay `label` command when an owner's direction reserves the work for people (then `/unclaim`); they may never remove it (`src/pkg/github/issue_unpark_command.go`, `src/pkg/github/issue_request_label.go`) | 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`) | @@ -112,7 +112,7 @@ Some hive-authored labels look like provenance but are read as signals, so they | `hive/partially-addressed` | Issues | Close-on-merge sweep, PR-claim label sync and task-list sweep | A merged PR covered only part of the issue ([#11931](https://github.com/hivecommons/hive/issues/11931)): applied instead of `hive/likely-done` when the PR has no closing keyword (`Fixes`/`Closes`/`Resolves #N`) for the issue, its body carries a remainder/out-of-scope paragraph, or none of the backtick-quoted paths cited in the issue body is among its changed files. No `/fixed` prompt is posted, `hive/likely-done` is suppressed, and the issue stays in the actionable pool; the `` comment lists the cited paths no merged PR changed as `Not yet touched: ...`. | Display; suppresses likely-done | Hive | Close-on-merge sweep for issues behind a confirmation gate | Hive removes it when a later merged PR fully covers the issue and `hive/likely-done` is applied; humans may remove it | Fixed label (`src/pkg/github/close_on_merge.go`, `src/pkg/github/task_list_sweep.go`) | | `hive/verified-open` | Issues | Verify-once kick path, PR-claim label sync and close-on-merge | A `hive/likely-done` / already-done claim from a merged PR was checked and the issue is NOT finished ([#11931](https://github.com/hivecommons/hive/issues/11931)): the agent that verified it labels the issue (`src/pkg/scheduler/kickmessage.go` "verify once" instruction) so later kicks say "already verified — implement the rest" and the claim sync never re-applies `hive/likely-done` from the same stale claim (`src/pkg/github/prclaims.go`). Merged-PR evidence, orthogonal to the stage: the issue keeps moving `010 → 020 → 030 → 040` as new work starts. | Suppresses likely-done; kick wording | Agent (verify-once kick) / Hive | Verify-once kick, claim sync | Human removes when the issue is really done, or close-on-merge closes the issue | Fixed label (`src/pkg/github/prclaims.go` `VerifiedOpenLabel`, `src/cmd/hive/verifyonce.go`) | | `hive/already-done` | Issues | Contributor queue, already-done verdict close path, and dashboard | Contributor already-done verdict/confirmation; default contributor skip label and done band. When the verdict cites a PR that the API verifies as merged on the default branch, Hive labels the issue and runs the normal completed close path; human-filed bugs close too unless `hive: needs-confirmation` or `issues.reporter_confirmation` opted into the reporter gate. A verdict that cites no PR/commit, or whose citation fails verification, is never labelled: Hive comments that the contributor reports it may be resolved and holds it from offers for `hub.contribute_already_done_hold_days`. | Contributor hard skip; dashboard display; conditional close | Hive/contributor flow | Contributor admission, verified verdict settlement, issue close gate | Human removes/reopens or confirms reporter-gated bugs | `hub.contribute_already_done_label`, fixed label (`src/pkg/config/hub_config.go:196-208`, `src/pkg/config/defaults.go:275-289`, `src/pkg/dashboard/contribute_verdict_settle.go`, `src/pkg/github/issue_close.go`) | -| `blocked` | Issues | Contributor queue, dashboard issue bands, un-park sweep | Always included in contributor skip patterns and default waiting band. Does not by itself stop spoke-agent enumeration unless also exempt/held/filtered. It parks the issue on a person for the un-park sweep (#12376): Hive keeps the "What to reply" notice on it, and `/hive approve` (lift and re-offer) or `/hive decision ` (lift with instructions) remove it; label approval removes it only when the App bot applied it. A contributor blocked verdict whose reason says a person must act (an admin, maintainer, owner or operator; no other item, upstream or release named) is labelled `needs-human` instead. The label records no reason: the dashboard row signal and BLOCKED pill hover name the open GitHub "blocked by" links when the issue has them (`Issue.DependsOn`), and otherwise say the label records no reason. Blocked-by links are read for actionable issues only, so held and parked rows always show the label-only text. | Contributor hard skip; display | Human, or Hive App on a contributor blocked verdict | Contributor admission/dashboard render | Remove label. Hive's hard-suppress reconcile (#12002) lifts a `blocked` whose newest label event is a `labeled` by the App bot once a PR referencing the issue merges after it (a PR in one of the hive's repos authored by the App bot or `project.ai_author`; a person's PR that only mentions the issue never counts), posting one note carrying ``; a human-applied (or re-applied) `blocked` is never lifted. | `hub.contribute_skip_labels`, dashboard bands (`src/pkg/config/hub_config.go:136-155`, `src/pkg/config/hub_config.go:469-492`, `src/docs/dashboard.md:105-140`) | +| `blocked` | Issues | Contributor queue, dashboard issue bands, un-park sweep | Always included in contributor skip patterns and default waiting band. Does not by itself stop spoke-agent enumeration unless also exempt/held/filtered. It parks the issue on a person for the un-park sweep (#12376): Hive keeps the "What to reply" notice on it, and `/hive approve` (lift and re-offer) or `/hive decision ` (lift with instructions) remove it; label approval removes it only when the App bot applied it. A contributor blocked verdict whose reason says a person must act (an admin, maintainer, owner or operator; no other item, upstream or release named) is labelled `needs-human` instead. The label records no reason: the dashboard row signal and BLOCKED pill hover name the open GitHub "blocked by" links when the issue has them (`Issue.DependsOn`), and otherwise say the label records no reason. Blocked-by links are read for actionable issues only, so held and parked rows always show the label-only text. | Contributor hard skip; display | Human, or Hive App on a contributor blocked verdict | Contributor admission/dashboard render | Remove label. Hive's hard-suppress reconcile (#12002) lifts a `blocked` whose newest label event is a `labeled` by the App bot once a PR referencing the issue merges after it (a PR in one of the hive's repos authored by the App bot or `project.ai_author`; a person's PR that only mentions the issue never counts), posting one note carrying ``; a human-applied (or re-applied) `blocked` is never lifted. The blocked sweep never lifts a contributor verdict's `blocked`: its marker-less lift is for review-backlog items only (see the review-backlog `blocked` row). | `hub.contribute_skip_labels`, dashboard bands (`src/pkg/config/hub_config.go:136-155`, `src/pkg/config/hub_config.go:469-492`, `src/docs/dashboard.md:105-140`) | | `needs-direction` (retired) | Issues | Issue stage reconciler (migration only) | Retired ([#12683](https://github.com/hivecommons/hive/issues/12683)): nothing writes it. `stage/045-needs-decision` is the single "issue parked for a maintainer ruling" signal (owner decision: `stage/085-needs-decision` is PR-only). An open issue still carrying it is read as parked (same hard suppress, same un-park), the issue stage reconciler adds `stage/045-needs-decision` and then removes the retired label, and the label definition is deleted from the repo once no open item carries it. The scanner's "needs-direction (scanner): …" comment may remain as the explanation text accompanying the 045 transition — no label. | Hard suppress until migrated | — (legacy) | Issue stage reconciler | Migrated to `stage/045-needs-decision` (`src/pkg/github/legacy_decision_labels.go`) | Fixed legacy spelling (`src/pkg/config/issue_filter.go`) | | `needs-decision` (retired) | Issues, PRs | Issue stage reconciler (migration only); PR lanes read it as a hold modifier until gone | Retired ([#12683](https://github.com/hivecommons/hive/issues/12683)): nothing writes it. The relay's `hive-open-issue --needs-decision` and the configured `project.issue_filter.hard_suppress_labels.needs_decision` / `hub.contribute_needs_decision_label` now default to `stage/045-needs-decision`; a configured legacy spelling (or `stage/085-needs-decision`) is upgraded. Migration as for `needs-direction`. | Hard suppress until migrated | — (legacy) | Issue stage reconciler | Migrated to `stage/045-needs-decision` (`src/pkg/github/legacy_decision_labels.go`) | `hub.contribute_needs_decision_label` (`src/pkg/config/hub_config.go`, `src/pkg/config/issue_filter.go`) | | `needs-triage`, `discussion`, `question`, `tracking`, `epic` | Issues | Contributor queue | Default contributor skip labels/patterns. | Contributor hard skip | Human/Hive | Contributor admission | Remove label or config | `hub.contribute_skip_labels`, `HIVE_CONTRIBUTE_SKIP_LABELS` (`src/pkg/config/hub_config.go:136-155`, `src/pkg/config/hub_config.go:469-492`) | diff --git a/src/docs/scale-envelope.md b/src/docs/scale-envelope.md index 2b25516bf8..867b19bf5c 100644 --- a/src/docs/scale-envelope.md +++ b/src/docs/scale-envelope.md @@ -34,7 +34,7 @@ ones to: 2. **Truncation must preserve the prioritization signal, not cut an arbitrary slice.** This holds today and is easy to assume backwards: - Issues are sorted by actionable rank tier, then **oldest first** within each tier before any cap is applied - (`RankActionableIssues`, `src/pkg/github/client.go:4813-4823`, descending `AgeMinutes`). + (`RankActionableIssues`, `src/pkg/github/client.go:4818-4828`, descending `AgeMinutes`). - PRs are sorted by **review class then oldest-first within class** (`SortPullRequestsForReview`, `src/pkg/github/review_priority.go:334`; fixes → refactors/docs → tests). diff --git a/src/pkg/github/client.go b/src/pkg/github/client.go index cfbb515b74..05dd48daab 100644 --- a/src/pkg/github/client.go +++ b/src/pkg/github/client.go @@ -1868,8 +1868,7 @@ func (c *Client) fetchIssues(ctx context.Context, repo string, now time.Time, re breakdown.Filtered++ breakdown.Blocked++ row := c.workIssue(repo, issue, labels, "filtered", blockedFilterReason(issue.GetBody())) - row.RecheckAfter, row.OpsTracking = blockedRecheck(issue.GetBody()) - row.RecheckDone = blockedRecheckDone(issue.GetBody()) + setBlockedRowFacts(&row, issue.GetBody(), blockedCounts[issue.GetNumber()]) details = append(details, row) continue } @@ -4624,6 +4623,12 @@ type RepoWorkIssue struct { // RecheckDone is set once the soak triage has stamped // `` into the body (hivecommons/hive#13311). RecheckDone bool `json:"recheck_done,omitempty"` + // ReviewBacklog (the body is a review-backlog item's) and OpenBlockedBy + // (GitHub's open "blocked by" count, #9839) decide whether + // ReconcileBlockedIssues may lift a marker-less block + // (liftBlockedMarkerless). + ReviewBacklog bool `json:"review_backlog,omitempty"` + OpenBlockedBy int `json:"open_blocked_by,omitempty"` } func repoWorkIssueFromIssue(issue Issue, bucket, reason string) RepoWorkIssue { diff --git a/src/pkg/github/issue_blocked.go b/src/pkg/github/issue_blocked.go index b530f725b0..18e900f8ff 100644 --- a/src/pkg/github/issue_blocked.go +++ b/src/pkg/github/issue_blocked.go @@ -31,6 +31,8 @@ import ( "context" "fmt" "log/slog" + "net/http" + "net/url" "regexp" "sort" "strconv" @@ -44,7 +46,9 @@ import ( // BlockedLabel is the workflow label that parks an issue on an unmerged PR // (or any outside blocker). It is reserved for agents (issue_request_label.go) // — the hive applies it from the review backlog and the blocked-on comment -// relay — and the contributor lane already refuses it as a workflow skip. +// relay, and a contributor relay applies it on a `blocked` verdict with no +// marker (hivecommons/hive#7924) — and the contributor lane already refuses +// it as a workflow skip. const BlockedLabel = "blocked" // ClaimBlockReasonBlockedPrefix prefixes the IssueClaimBlockReason for a @@ -137,6 +141,23 @@ func blockedRecheckDone(body string) bool { return strings.Contains(body, RecheckDoneMarker) } +// blockedReviewBacklogFiling reports whether body is a review-backlog item's +// (reviewBacklogFooter ends every one): the only hive path whose marker-less +// `blocked` liftBlockedMarkerless may lift (hivecommons/hive#13364). +func blockedReviewBacklogFiling(body string) bool { + return strings.Contains(body, reviewBacklogFooter) +} + +// setBlockedRowFacts records on a blocked work row what the sweep reads from +// the issue body and GitHub's open "blocked by" count from the same payload +// (#9839), so ReconcileBlockedIssues needs no re-read of either. +func setBlockedRowFacts(row *RepoWorkIssue, body string, openBlockedBy int) { + row.RecheckAfter, row.OpsTracking = blockedRecheck(body) + row.RecheckDone = blockedRecheckDone(body) + row.ReviewBacklog = blockedReviewBacklogFiling(body) + row.OpenBlockedBy = openBlockedBy +} + // blockedStageReason is the IssueStageFor reason for an issue wearing the // blocked label: the enumeration's reason when the cycle recorded one (it // names the PR), else the bare label. @@ -276,6 +297,10 @@ type blockedIssueTarget struct { recheckAfter time.Time opsTracking bool recheckDone bool + // reviewBacklog: the body is a review-backlog item's; openBlockedBy: + // GitHub's open "blocked by" count. Both gate liftBlockedMarkerless. + reviewBacklog bool + openBlockedBy int } // ReconcileBlockedIssues walks the cycle's blocked issues (filtered rows @@ -289,10 +314,12 @@ type blockedIssueTarget struct { // deadline has passed loses `blocked` with a one-line note (once per // deadline) so the next enumeration re-triages it; an ops-tracking row on the // hive's own project gets soak evidence instead (runRecheckSoak) and keeps -// `blocked`, other ops-tracking rows are left alone. A row with no marker, -// no deadline and no ops-tracking whose `blocked` the hive itself applied is -// lifted as a defect (liftBlockedMarkerless, hivecommons/hive#13364). Lookup -// failures are counted and skipped. +// `blocked`, other ops-tracking rows are left alone. A review-backlog item +// with no marker, no deadline, no ops-tracking and no open native blocker +// whose `blocked` the hive itself applied is lifted as a defect +// (liftBlockedMarkerless, hivecommons/hive#13364); every other marker-less +// block is a relay's verdict or a person's and stays. Lookup failures are +// counted and skipped. func ReconcileBlockedIssues(ctx context.Context, client *Client, result *ActionableResult, logger *slog.Logger) BlockedIssueResult { var res BlockedIssueResult if client == nil || client.client == nil || result == nil { @@ -309,7 +336,7 @@ func ReconcileBlockedIssues(ctx context.Context, client *Client, result *Actiona if row.Number <= 0 || row.Bucket != workBucketFiltered || !IsBlockedIssueReason(row.Reason) || !hasBlockedLabel(row.Labels) { continue } - targets = append(targets, blockedIssueTarget{repo: row.Repo, number: row.Number, labels: row.Labels, reason: row.Reason, recheckAfter: row.RecheckAfter, opsTracking: row.OpsTracking, recheckDone: row.RecheckDone}) + targets = append(targets, blockedIssueTarget{repo: row.Repo, number: row.Number, labels: row.Labels, reason: row.Reason, recheckAfter: row.RecheckAfter, opsTracking: row.OpsTracking, recheckDone: row.RecheckDone, reviewBacklog: row.ReviewBacklog, openBlockedBy: row.OpenBlockedBy}) } } return client.reconcileBlockedTargets(ctx, targets, logger) @@ -335,7 +362,7 @@ func (c *Client) SweepBlockedIssues(ctx context.Context, opts BlockedSweepOption var targets []blockedIssueTarget for _, repo := range repos { owner, repoName := c.splitRepo(repo) - issues, err := c.listOpenBlockedIssues(ctx, owner, repoName) + issues, blockedBy, err := c.listOpenBlockedIssues(ctx, owner, repoName) if err != nil { return BlockedIssueResult{}, err } @@ -350,13 +377,15 @@ func (c *Client) SweepBlockedIssues(ctx context.Context, opts BlockedSweepOption body := issue.GetBody() at, ops := blockedRecheck(body) targets = append(targets, blockedIssueTarget{ - repo: repo, - number: issue.GetNumber(), - labels: labels, - reason: blockedFilterReason(body), - recheckAfter: at, - opsTracking: ops, - recheckDone: blockedRecheckDone(body), + repo: repo, + number: issue.GetNumber(), + labels: labels, + reason: blockedFilterReason(body), + recheckAfter: at, + opsTracking: ops, + recheckDone: blockedRecheckDone(body), + reviewBacklog: blockedReviewBacklogFiling(body), + openBlockedBy: blockedBy[issue.GetNumber()], }) } } @@ -401,8 +430,8 @@ func (c *Client) reconcileBlockedTargets(ctx context.Context, targets []blockedI } } if !ok { - // No tracked PR, no deadline, no ops-tracking: a block the hive - // applied itself with no marker is always a bug (a blocked + // No tracked PR, no deadline, no ops-tracking: a review-backlog + // item the hive blocked with no marker is a bug (a blocked // filing folded into an open twin, hivecommons/hive#13364), so // lift it. A maintainer's or a relay's marker-less label // (hivecommons/hive#13267) is left alone: nothing to lift, but @@ -509,15 +538,27 @@ func stripBlockedHelpWanted(ctx context.Context, client *Client, t blockedIssueT res.Stripped++ } -// liftBlockedMarkerless lifts `blocked` from an issue with no blocked-on -// marker, no recheck-after deadline and no ops-tracking marker when the -// label's most recent application was by this hive (hivecommons/hive#13364): -// nothing the hive writes applies `blocked` without a marker, so such a block -// is a defect and would otherwise never lift. Reports whether the label came -// off. A human-applied label, an unreadable timeline, or a client with no -// hive identity configured leaves the issue alone, the last with one WARN so -// the stuck block is at least visible. +// liftBlockedMarkerless lifts `blocked` from a review-backlog item with no +// blocked-on marker, no recheck-after deadline and no ops-tracking marker +// when the label's most recent application was by this hive +// (hivecommons/hive#13364): the review backlog always writes the marker with +// the label, so such a block is a defect and would otherwise never lift. +// Reports whether the label came off. +// +// The actor alone cannot attribute the block: a contributor relay's +// `blocked` verdict is applied with a hub-minted task token, so its labeled +// event names the same App bot, and it carries no marker by design — lifting +// it is a human's (`/hive approve`, hivecommons/hive#7924 and #12376). Lifting +// those put the issue back in the ready band, the next agent hit the same +// blocker and the relay re-applied the label, daily. So any other issue, or +// one GitHub still reports an open "blocked by" dependency on (#9839), is left +// alone before the timeline is read. A human-applied label, an unreadable +// timeline, or a client with no hive identity configured leaves the issue +// alone too, the last with one WARN so the stuck block is at least visible. func liftBlockedMarkerless(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++ @@ -732,30 +773,45 @@ func (c *Client) followSupersededChain(ctx context.Context, repo string, number, return number, true } -// listOpenBlockedIssues lists open issues with the `blocked` label in owner/repo. -func (c *Client) listOpenBlockedIssues(ctx context.Context, owner, repo string) ([]*gh.Issue, error) { - opts := &gh.IssueListByRepoOptions{ - State: "open", - Labels: []string{BlockedLabel}, - ListOptions: gh.ListOptions{PerPage: 100}, - } +// listOpenBlockedIssues lists open issues with the `blocked` label in +// owner/repo and, keyed by number, the open "blocked by" count each payload's +// issue_dependencies_summary reports (go-github drops it; see +// listOpenIssuesWithBlockedCounts). +func (c *Client) listOpenBlockedIssues(ctx context.Context, owner, repo string) ([]*gh.Issue, map[int]int, error) { var all []*gh.Issue + blockedBy := map[int]int{} + page := 1 for { - issues, resp, err := c.client.Issues.ListByRepo(ctx, owner, repo, opts) + q := url.Values{} + q.Set("state", "open") + q.Set("labels", BlockedLabel) + q.Set("per_page", "100") + q.Set("page", strconv.Itoa(page)) + req, err := c.client.NewRequest(http.MethodGet, fmt.Sprintf("repos/%s/%s/issues?%s", owner, repo, q.Encode()), nil) + if err != nil { + return all, blockedBy, err + } + var issues []*issueWithDependencies + resp, err := c.client.Do(ctx, req, &issues) if err != nil { - return all, err + return all, blockedBy, err } for _, is := range issues { - if is != nil && !is.IsPullRequest() { - all = append(all, is) + if is == nil || is.IsPullRequest() { + continue + } + issue := is.Issue + all = append(all, &issue) + if is.DependenciesSummary != nil && is.DependenciesSummary.BlockedBy > 0 { + blockedBy[issue.GetNumber()] = is.DependenciesSummary.BlockedBy } } - if resp.NextPage == 0 { + if resp == nil || resp.NextPage == 0 { break } - opts.ListOptions.Page = resp.NextPage + page = resp.NextPage } - return all, nil + return all, blockedBy, nil } // mentionPattern matches a GitHub @login that is not part of a path, an diff --git a/src/pkg/github/issue_blocked_test.go b/src/pkg/github/issue_blocked_test.go index 83637ae5a2..f02de82e5f 100644 --- a/src/pkg/github/issue_blocked_test.go +++ b/src/pkg/github/issue_blocked_test.go @@ -260,6 +260,10 @@ func TestReconcileBlockedIssues(t *testing.T) { _, _ = io.WriteString(w, `[{"id":1,"body":"`+reviewBacklogLinkMarker+` also raised on PR #9"}]`) case r.Method == "GET" && r.URL.Path == "/repos/o/r/issues/70/timeline": _, _ = io.WriteString(w, `[{"event":"labeled","created_at":"2026-10-20T10:00:00Z","label":{"name":"help wanted"},"actor":{"login":"maintainer","type":"User"}},{"event":"labeled","created_at":"2026-10-20T10:05:00Z","label":{"name":"blocked"},"actor":{"login":"`+testBot+`","type":"Bot"}}]`) + case r.Method == "GET" && (r.URL.Path == "/repos/o/r/issues/80/comments" || r.URL.Path == "/repos/o/r/issues/90/comments"): + _, _ = io.WriteString(w, `[{"id":1,"body":"Blocked: the upstream API this needs is not released yet."}]`) + case r.Method == "GET" && (r.URL.Path == "/repos/o/r/issues/80/timeline" || r.URL.Path == "/repos/o/r/issues/90/timeline"): + _, _ = 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" && strings.HasSuffix(r.URL.Path, "/comments"): @@ -289,14 +293,22 @@ func TestReconcileBlockedIssues(t *testing.T) { // A relay's blocked verdict, no tracked PR (hivecommons/hive#13267): // nothing to lift, but `help wanted` still comes off. {Repo: "o/r", Number: 60, Labels: []string{"blocked", "help wanted"}, Bucket: workBucketFiltered, Reason: "blocked"}, - // A hive-applied `blocked` with no marker anywhere (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"}, + // A hive-applied `blocked` with no marker anywhere on a + // 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`. + {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. + {Repo: "o/r", Number: 90, Labels: []string{"blocked"}, Bucket: workBucketFiltered, Reason: "blocked", ReviewBacklog: true, OpenBlockedBy: 1}, }}, }} res := ReconcileBlockedIssues(context.Background(), c, result, nil) - if res.Items != 6 || res.Unblocked != 3 || res.Stripped != 2 || res.Errors != 1 { + if res.Items != 8 || res.Unblocked != 3 || res.Stripped != 3 || res.Errors != 1 { t.Fatalf("result = %+v", res) } mu.Lock() @@ -309,12 +321,14 @@ func TestReconcileBlockedIssues(t *testing.T) { "GET /repos/o/r/issues/30/comments", "DELETE /repos/o/r/issues/30/labels/blocked", "GET /repos/o/r/issues/60/comments", - "GET /repos/o/r/issues/60/timeline", "DELETE /repos/o/r/issues/60/labels/help wanted", "GET /repos/o/r/issues/70/comments", "GET /repos/o/r/issues/70/timeline", "DELETE /repos/o/r/issues/70/labels/blocked", "POST /repos/o/r/issues/70/comments", + "GET /repos/o/r/issues/80/comments", + "DELETE /repos/o/r/issues/80/labels/help wanted", + "GET /repos/o/r/issues/90/comments", } { if !strings.Contains(joined, want) { t.Errorf("missing call %q in:\n%s", want, joined) @@ -326,6 +340,15 @@ 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", + "GET /repos/o/r/issues/90/timeline", + "DELETE /repos/o/r/issues/90/labels/blocked", + "POST /repos/o/r/issues/90/comments", } { if strings.Contains(joined, never) { t.Errorf("unexpected call %q in:\n%s", never, joined) @@ -458,6 +481,10 @@ func TestEnumerateActionableRecordsBlockedRecheckAfter(t *testing.T) { {Number: 1, Title: "soak", User: wireUser{"alice"}, Labels: []wireLabel{{Name: "blocked"}}, CreatedAt: hoursAgo(3), Body: "checklist\n" + gfi.OpsTrackingMarker + "\n" + gfi.RecheckAfterMarker(at)}, {Number: 2, Title: "bare", User: wireUser{"bob"}, Labels: []wireLabel{{Name: "blocked"}}, CreatedAt: hoursAgo(2)}, + // liftBlockedMarkerless reads both off the row: the review-backlog + // footer and GitHub's open "blocked by" count. + {Number: 3, Title: "backlog", User: wireUser{"hive-app[bot]"}, Labels: []wireLabel{{Name: "blocked"}}, CreatedAt: hoursAgo(1), + Body: "Finding: x\n\n" + reviewBacklogFooter + "\n", IssueDependenciesSummary: &wireDepsSummary{BlockedBy: 2, TotalBlockedBy: 2}}, } server := httptest.NewServer(buildMux(t, org, repo, issues, []wirePR{})) t.Cleanup(server.Close) @@ -473,9 +500,12 @@ func TestEnumerateActionableRecordsBlockedRecheckAfter(t *testing.T) { if r := rows[1]; r.Bucket != workBucketFiltered || r.Reason != "blocked until 2026-10-21T21:20:00Z" || !r.RecheckAfter.Equal(at) || !r.OpsTracking { t.Fatalf("deadline row = %+v", r) } - if r := rows[2]; r.Bucket != workBucketFiltered || r.Reason != "blocked" || !r.RecheckAfter.IsZero() || r.OpsTracking { + if r := rows[2]; r.Bucket != workBucketFiltered || r.Reason != "blocked" || !r.RecheckAfter.IsZero() || r.OpsTracking || r.ReviewBacklog || r.OpenBlockedBy != 0 { t.Fatalf("bare row = %+v", r) } + if r := rows[3]; r.Bucket != workBucketFiltered || r.Reason != "blocked" || !r.ReviewBacklog || r.OpenBlockedBy != 2 { + t.Fatalf("backlog row = %+v", r) + } } // The sweep lifts `blocked` from a row whose recheck-after deadline has @@ -909,6 +939,91 @@ 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) { + var mu sync.Mutex + var calls []string + lifted := false + 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": 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}}, + } + if !done { + items = append(items, map[string]any{"number": 70, "state": "open", "labels": []any{map[string]any{"name": "blocked"}}, "body": backlogBody}) + } + _ = json.NewEncoder(w).Encode(items) + 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."}]`) + 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": + mu.Lock() + lifted = true + mu.Unlock() + _, _ = io.WriteString(w, `[]`) + case r.Method == "POST" && r.URL.Path == "/repos/o/r/issues/70/comments": + _, _ = io.WriteString(w, `{"id":9}`) + default: + w.WriteHeader(http.StatusNotFound) + _, _ = fmt.Fprintf(w, `{"path":%q}`, r.URL.Path) + } + })) + defer srv.Close() + c := testClient(t, srv.URL) + c.appBotLogin = testBot + for pass := 1; pass <= 3; pass++ { + res, err := c.SweepBlockedIssues(context.Background(), BlockedSweepOptions{Repos: []string{"o/r"}}) + if err != nil { + t.Fatalf("pass %d: SweepBlockedIssues failed: %v", pass, err) + } + wantUnblocked := 0 + if pass == 1 { + wantUnblocked = 1 + } + if res.Unblocked != wantUnblocked || res.Errors != 0 { + t.Fatalf("pass %d: res = %+v, want Unblocked=%d Errors=0", pass, res, wantUnblocked) + } + } + 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", + } { + if !strings.Contains(joined, want) { + t.Errorf("missing call %q in:\n%s", want, 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", + } { + if strings.Contains(joined, never) { + t.Errorf("unexpected call %q in:\n%s", never, joined) + } + } +} + // Issue 14194: SweepBlockedIssues lists open issues with `blocked` label directly // and reconciles them. func TestSweepBlockedIssues(t *testing.T) { diff --git a/src/pkg/github/webhook_item_patch.go b/src/pkg/github/webhook_item_patch.go index aec4a8888a..b2dd376e6c 100644 --- a/src/pkg/github/webhook_item_patch.go +++ b/src/pkg/github/webhook_item_patch.go @@ -47,9 +47,10 @@ type WebhookItemPatch struct { } // classifyWebhookIssue places one open issue the way fetchIssues would, -// minus the list-wide passes. Side effects (reporter-trust label writes) are -// deliberately not performed here. -func (c *Client) classifyWebhookIssue(repo string, issue *gh.Issue, labels []string, now time.Time) WebhookItemPatch { +// minus the list-wide passes. blockedBy is the payload's open "blocked by" +// count (getIssueWithBlockedCount). Side effects (reporter-trust label +// writes) are deliberately not performed here. +func (c *Client) classifyWebhookIssue(repo string, issue *gh.Issue, blockedBy int, labels []string, now time.Time) WebhookItemPatch { issueFilter := c.getIssueFilter() author := safeGetLogin(issue.GetUser()) sidelined := func(bucket, reason string) WebhookItemPatch { @@ -83,8 +84,7 @@ func (c *Client) classifyWebhookIssue(repo string, issue *gh.Issue, labels []str } if hasBlockedLabel(labels) { row := c.repoWorkIssue(repo, issue, labels, "filtered", blockedFilterReason(issue.GetBody())) - row.RecheckAfter, row.OpsTracking = blockedRecheck(issue.GetBody()) - row.RecheckDone = blockedRecheckDone(issue.GetBody()) + setBlockedRowFacts(&row, issue.GetBody(), blockedBy) return WebhookItemPatch{Bucket: WebhookBucketSidelined, WorkIssue: &row} } if labelPresent(labels, issueNeedsReporterConfirmationLabel) { diff --git a/src/pkg/github/webhook_item_refresh.go b/src/pkg/github/webhook_item_refresh.go index 75101ac4cc..dc455f9f3e 100644 --- a/src/pkg/github/webhook_item_refresh.go +++ b/src/pkg/github/webhook_item_refresh.go @@ -138,7 +138,7 @@ func (c *Client) FetchWebhookItemSnapshot(ctx context.Context, repo string, numb // issue payload lacks the PR fields, and the PR-side delivery for it // carries its own re-read. if snap.Open() && !snap.IsPR { - snap.Patch = c.classifyWebhookIssue(repo, issue, labels, now) + snap.Patch = c.classifyWebhookIssue(repo, issue, blockedBy, labels, now) } return snap, nil } diff --git a/src/pkg/github/webhook_item_refresh_test.go b/src/pkg/github/webhook_item_refresh_test.go index c7077a156c..39224e464f 100644 --- a/src/pkg/github/webhook_item_refresh_test.go +++ b/src/pkg/github/webhook_item_refresh_test.go @@ -208,3 +208,35 @@ func TestFetchWebhookItemSnapshotRefusesDuringRateLimitCaution(t *testing.T) { t.Fatalf("err = %v, want ErrRateLimitCaution", err) } } + +// A webhook re-read of a blocked issue records the same row facts the +// enumeration does, so a patched row cannot open liftBlockedMarkerless on +// an issue GitHub still reports an open "blocked by" on. +func TestFetchWebhookItemSnapshotBlockedRowFacts(t *testing.T) { + clock := &webhookTestClock{now: time.Date(2026, 10, 28, 12, 0, 0, 0, time.UTC)} + resetRESTAccountingForTest(t, clock.now) + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path != "/repos/org/repo/issues/5" { + t.Errorf("unexpected GitHub call %s %s", r.Method, r.URL.Path) + w.WriteHeader(http.StatusInternalServerError) + return + } + _ = json.NewEncoder(w).Encode(map[string]any{ + "number": 5, "title": "Review backlog (style): x", "state": "open", + "user": map[string]any{"login": "hive-app[bot]"}, + "labels": []map[string]any{{"name": "blocked"}}, + "body": "Finding: x\n\n" + reviewBacklogFooter + "\n", + "issue_dependencies_summary": map[string]any{"blocked_by": 1, "total_blocked_by": 1}, + }) + })) + t.Cleanup(srv.Close) + c := newTestClient(t, srv, "org", []string{"repo"}) + snap, err := c.FetchWebhookItemSnapshot(context.Background(), "repo", 5, false) + if err != nil { + t.Fatal(err) + } + row := snap.Patch.WorkIssue + if row == nil || !row.ReviewBacklog || row.OpenBlockedBy != 1 { + t.Fatalf("blocked row = %+v, want ReviewBacklog and OpenBlockedBy=1", row) + } +}