Skip to content

🐛 automerge: name held workflow runs and stop base-refreshing them - #18945

Merged
hivecommons-hive[bot] merged 7 commits into
hivecommons:v6from
Danathar:fix/held-runs-refresh-and-reason
Nov 18, 2026
Merged

hivecommons-hive[bot] merged 7 commits into
hivecommons:v6from
Danathar:fix/held-runs-refresh-and-reason

Conversation

@Danathar

Copy link
Copy Markdown
Contributor

Summary

Sometimes GitHub holds a PR's workflow runs for "Approve and run" and the hive will not approve them, for example an untrusted fork head. Until now the hive never noticed this. Two things went wrong:

This PR shows the held runs as the blocker and stops the refresh loop. The trust policy is unchanged: untrusted fork runs are still never approved automatically.

What was actually happening

  • server#686 (fork, role/untrusted). The head has one green check: prow / prow, from a pull_request_target run. Its pull_request runs (Build image artifacts, Unit tests, Docs checks, Lint workflows) are all action_required. That green check makes CIStatus "success". The approval probe in EnrichCIStatus only ran on "pending" heads, so CIActivity.WorkflowApproval stayed nil. missingCheckRefreshSkip therefore saw "12 required checks missing, CI settled" and merged the base in.
    • The loop guard was per (PR, check), so with 12 missing checks each base move could buy another update.
  • documentation#1709 and feat: document sources UI in knowledge panel #1711 (same-repo, opened by github-actions[bot]). These heads have no check runs at all, so they already read "pending" and were probed. The bug there was only the reason shown: 050, "waiting for a verdict".
  • utah#1334 and test: knowledge coverage boost (53.1% → 88.8%) #1277. Same shape as server#686: Prow passed and Build Utah is held.

The fix

  1. Probe the heads that may be held. workflowApprovalProbeWanted: CI pending, as before, or CI green while a required check never reported at all. A red head is still not probed. Only a head that might be held pays for the listing (✨ Activity Monitor chevrons: active-with-text / icon-only spec, CI and review ring glyph, workflow-approval stall caption #16599). The probe now runs after the protection facts are attached, because it needs MissingRequiredChecks.
  2. Record when the hive won't approve. SweepWorkflowApprovals now marks a head Denied when no gated run on it is trusted, or when governor.ci.auto_approve_workflows is off.
    • The mark lives on the per-head ledger, like the existing permission refusal. workflowApprovalWithLedger carries it onto cycles that skip the sweep: conserve budget, off-cadence cycles, webhook wakes.
    • PullRequest.HeldWorkflowRunIDs() returns the run ids only when Denied or PermissionDenied is set. A trusted head (Renovate, Dependabot, the App, a dashboard-admitted head) waits for the sweep as before and is never parked.
  3. Show the blocker. A new stage fact, HeldWorkflowRuns, is published with the shared-CI index the same way as the fork-guard checks, and round-trips through Facts.
    • HeldWorkflowRunsStage parks the PR at 085 with reason workflow-approval-required:held-runs:<run ids>. This wins over the lane's next reason: author association, no linked issue, no verdict, or a lane error.
    • It leaves alone closed, merged and draft PRs, handed-off lanes, held and sentinel-flagged PRs, and lanes that already report workflow-approval-required:<ctx> (the /ok-to-test path) or unauthorized:<step>.
    • The 085 comment, the dashboard caption and the decision popover name the runs and the person's step. Approve on the dashboard still works here: it admits the head, and the sweep then approves the runs.
    • The reason clears on the first enumeration after the runs start or the head changes.
  4. Stop the refresh loop.
    • A held head is skipped via the existing workflow-approval-pending skip, which now sees the probe.
    • After one update, every check missing at that time is marked as refreshed. A PR missing 12 checks is updated once, not 12 times. A check that becomes required later still gets its one update.
    • The memo is still in memory, so a restart allows one more update. For held heads the probe now prevents that update anyway.

Acceptance, case by case

  • Untrusted fork with every run held: never base-refreshed; parks at 085 with the run ids.
  • Same-repo github-actions[bot] PR with held runs the policy doesn't trust: the same 085 row instead of 050.
  • Trusted head: approved as today; it is not parked while the sweep has not decided.
  • Runs start, or a new head: the reason clears on the next enumeration.
  • Observe-only repo (auto-merge off): no base-refresh push on such a PR.

Setting note: github-actions[bot] in auto_approve_workflow_actors

github-actions[bot] is not added to the default in this PR.

  • A trusted author covers every gated run on the head, whoever pushed it.
  • A github-actions[bot]-authored PR can only come from a workflow in the repository itself, so for same-repo heads the risk is low.
  • Still, putting it in the default would auto-approve every workflow-opened PR in every hive. That is a policy call for the owners.
  • A hive that wants it for its analytics, promotion and ISO-record PRs can add it in yaml today.
  • The setting is yaml-only (settings_parity_allowlist.txt:261). A dashboard control for it is a parity follow-up and isn't in this PR.

Existing issues

I searched for "missing-check base refresh", "workflow approval" plus "fork", "action_required" plus "untrusted", and auto_approve_workflow_actors, and found no issue covering this.

Tests

  • pkg/github:
    • TestWorkflowApprovalProbeWanted: covers pending, green with a missing required check, green with every check, red, and no listing.
    • TestHeldWorkflowRunIDs.
    • TestSweepWorkflowApprovalsMarksDeniedHeads: covers a trusted head; an untrusted head, including the ledger carrying the denial onto a fresh probe; an owner admission lifting it; and auto-approval off.
  • cmd/hive:
    • TestRefreshMissingCheckBehindPRs_HeldForkHeadLeftAlone: server#686 in miniature.
    • TestRefreshMissingCheckBehindPRs_OncePerSetOfMissingChecks.
    • TestStageHeldWorkflowRunsIndex.
  • pkg/stageengine:
    • TestClassifyStageHeldWorkflowRunsParkForMaintainer: what it overrides and what it leaves alone.
    • TestHeldWorkflowRunsRoundTripFacts.
    • The goldens' decisionCause mirror covers the new reason.
  • pkg/dashboard:
    • TestDecisionForPRHeldWorkflowRuns.
    • A humanizeStageReason case.

The probe change is tested through its predicate rather than a full EnrichCIStatus fixture.

Locally I ran only gofmt -l (AGENTS.md bans local go test/go build/go vet) and check-docs-citations.py, which verified 2163 references. CI is the test run.

Appendix: code refs

  • src/pkg/github/client.go (EnrichCIStatus) and src/pkg/github/workflow_approval.go (workflowApprovalProbeWanted, HeldWorkflowRunIDs, PRWorkflowApproval.Denied)
  • src/pkg/github/workflow_auto_approval.go: policyDenied ledger bit, markWorkflowApprovalDenied, sweep changes
  • src/cmd/hive/stage_shared_ci.go (stageHeldWorkflowRuns), src/cmd/hive/merge_eligibility.go (policy wiring)
  • src/pkg/github/automerge/automerge_stage_labels.go, automerge_stage_sharedci.go (observation), automerge_stage_human.go (085 cause)
  • src/pkg/stageengine/derive_pr_classify.go (HeldWorkflowRunsStage), derive_pr.go, facts.go, prstage/{reasons,causes,types}.go
  • src/pkg/dashboard/stage_tracker_caption.go, stage_tracker_decision_pr.go
  • src/cmd/hive/missing_check_base_refresh.go: loop guard
  • Docs: stage-labels.md (new 085 row), operator-reference/runtime-and-quota.md, operator-reference/sweeps-and-operations.md, github-write-surface.md

🤖 Generated with Claude Code

https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1

A PR whose workflow runs GitHub holds for approval, and that the hive will
not approve, was invisible: the approval probe ran only on pending heads, so
a fork head whose pull_request_target check (Prow) passed read green, the
missing-check base refresh merged the base into it again and again
(projectbluefin/server#686: three pushes, every new head held again), and
the activity monitor showed the lane's next reason ("author association",
"waiting for a verdict").

- Probe green heads that are missing a required check too.
- The approval sweep records, per head, when it will not approve the runs
  (no trusted run, or auto-approval off); the ledger carries it onto the
  cycles that skip the sweep. PullRequest.HeldWorkflowRunIDs reads it.
- The stage engine parks such a PR at 085 with reason
  workflow-approval-required:held-runs:<run ids>, over the lane's next
  reason; the 085 comment and the dashboard popover name the runs.
- The missing-check base refresh marks every check missing at the time
  after one update, so a PR missing twelve checks is updated once.

The trust policy is unchanged.

Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 18, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign kellyaa for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubestellar-prow kubestellar-prow Bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Nov 18, 2026
@hivecommons-hive

hivecommons-hive Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

@Danathar this PR is back in your court (stage/072-returned-to-contributor). The hive will not merge it until the head changes.

Review asks:

  • the branch is behind the base and Hive cannot update it; enable "allow edits by maintainers" or rebase

Reply here or push a new head to this branch (same sign-off); CI and the review swarm re-run automatically and the PR returns to the normal path.

Queued in your relay fix queue (7 waiting): fixes are handed out before new work as soon as you have capacity.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Scanner triage (fork PR, comment only): the PR Type check fails because the title fix(automerge): … doesn't start with a type emoji. Retitle it with a leading 🐛, e.g. 🐛 fix(automerge): name held workflow runs and stop base-refreshing them. coverage is red too, but the branch is 210 commits behind v5, so merge or rebase v5 before diagnosing it.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.327

@hivecommons-hive

Copy link
Copy Markdown
Contributor

scanner triage @2a7c8fb: two items. (1) PR Type fails because the title has no leading emoji; suggested title: 🐛 fix(automerge): name held workflow runs and stop base-refreshing them. (2) coverage fails (exit 1); the branch is 210 commits behind v5 (NOT_REACHABLE_FORK, not a shared incident), so syncing with v5 and re-running is the first step before reading the coverage log. Head is in a fork, so no push from the hive.


🐝 Hive Agent: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

— hive: agent=scanner backend=claude model=claude-sonnet-5-5 claude=2.1.327

@Danathar Danathar changed the title fix(automerge): name held workflow runs and stop base-refreshing them 🐛 automerge: name held workflow runs and stop base-refreshing them Nov 18, 2026
The per-package coverage gate counts only prstage's own tests.

Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

✅ Resolved: no conflicting open PRs or same-file overlaps remain against v6.

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read the diff and the tree at 2ff7a8a. The held-runs park and the probe widening look correct to me: HeldWorkflowRunIDs only fires once the sweep has set Denied/PermissionDenied, so a trusted head still waits for the sweep, and workflowApprovalWithLedger carries both flags per head.

One low-severity point, on the once-per-set change (inline). Everything else I checked held up.

— hive: agent=reviewer-2 backend=claude model=claude-sonnet-5-5 claude=2.1.327

…date

Review on hivecommons#18945: a missing check with no evidence it runs anywhere was
marked refreshed with the rest, so it never earned its own update once its
workflow landed on the base.

Signed-off-by: Danathar <6772335+Danathar@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BQYnPGFJx81c8JXR3o1sg1
@hivecommons-hive
hivecommons-hive Bot merged commit 4371b27 into hivecommons:v6 Nov 18, 2026
72 of 73 checks passed
@hivecommons-hive

hivecommons-hive Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor.

Evidence bundle `#18945875f860` sha256:a3150a4f354c94e939d4da1c2daf2cf7bb79a178db0bdc0b075d33acb84fb3ae — download from the dashboard or `hivectl review evidence #18945`.

merged by Hive trusted-author auto-merge: author Danathar holds role owner and GitHub permission maintain on repo; CI green at 875f860.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author/human A person pushed this PR themselves dco-signoff: yes Indicates the PR's author has signed the DCO. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants