Repository navigation
✨ feat(github): auto-approve gated Actions runs for trusted actors - #16736
Conversation
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Open PR overlap checkBase branch: Conflicts are checked with every PR merged onto the current tip of
|
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. hive/awaiting-ci: CI pending — sweep will merge when green. 🐝 Hive Agent: — hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 Review findings from docs-currency (read at head aa82bc7) The new text in
Hive filed review findings that do not block this PR as backlog items:
Cap: 10 backlog item(s) per PR per day. Review findings from Correctness review (head No in-scope blocker. The once-per-head claim, the fresh One low advisory, not blocking:
Review findings from Read the implementation against What I verified (correct)
Finding — docs contradict the code (medium)
Why this needs the owner, not me The PR body itself says the default-on question "was raised for owner sign-off on #16681 and still applies here". The change (a) raises the App's required permission from Actions: Read to Read and write in Review findings from Code reads correct to me; routing for a permissions decision, not a defect. What I verified on
Already decided, not re-asked: per #16603 (owner-authored) the default is The one thing only a human can do: this PR changes the documented App requirement from Actions: Read to Actions: Read and write ( No findings beyond that. I have not approved or changed anything. Review findings from docs-currency (delta re-review at 2b258e6) Fixed since aa82bc7: Still present (in-scope): |
There was a problem hiding this comment.
docs-currency — read at head 9e1821e.
1. docs/github-app-setup.md and docs/acmm-policy-matrix.md now contradict the default-on behavior this PR ships (in-scope, medium).
docs/github-app-setup.md:46 still states "Hive does not require Actions: Read and write for bot workflow-run approvals; Actions: Read is enough to inspect runs. The one direct approval Hive performs — [registry-trusted contributor lane] — does need Read and write", the permission matrix at :43 lists Actions Read | Read | Read for every level, and :93 says "If GitHub holds trusted Dependabot/App/clanker runs in action_required, Hive posts /ok-to-test". docs/acmm-policy-matrix.md:195-203 has a whole section titled "Workflow approval, not App Actions-write permission" asserting "the App needs no Actions-write grant" for exactly the dependabot/App actors this PR targets.
With this PR, SweepWorkflowApprovals (src/pkg/github/workflow_auto_approval.go:245-342) POSTs /actions/runs/{id}/approve with the App token by default (AutoApproveWorkflowsEnabled is nil-true, src/pkg/config/governor_ci.go:22-24) for those same actors, and on 403/404 records permission_error and flips the CI caption to "CI waiting · needs workflow approval on GitHub … the App lacks the actions: write permission" (src/pkg/dashboard/stage_tracker_activity.go:284-288). An operator who followed github-app-setup.md as written (Actions: Read, relying on the hive-ok-to-test workflow, which automerge_held_runs.go:124 "never approves a run with the App token") will on upgrade see permission_errors climb and a caption telling them to click Approve, while the existing /ok-to-test path is concurrently handling the same head. None of the new text (runtime-and-quota.md:265-301, webhooks.md:117-118) mentions /ok-to-test or github-app-setup.md.
Requested change: (a) in docs/github-app-setup.md:43/46/93 state that the default-on governor.ci.auto_approve_workflows sweep requires Actions: Read and write, and that operators keeping Actions at Read should set it to false (or accept the permanent permission_errors / caption); (b) retitle/reword docs/acmm-policy-matrix.md:195-203 so it no longer claims the App needs no Actions-write grant for dependabot/App runs; (c) add one sentence to runtime-and-quota.md ~line 292 saying how this sweep relates to the existing /ok-to-test path (which runs first / which one an operator should expect to act).
Everything else I checked lines up with the code: lgtm default (client.go:1485), ci_rerun kind (writeback/kinds.go:86), optional_sweep_every_n_cycles and cached-snapshot SkipOptional (main_eval_cycle.go:509-517), log/caption strings, the /api/status field shape, and the settings-parity allowlist.
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
The sweep trusted a PR for the automerge label alone, which is bound to no head and names no approver. Read the stage record's head-bound admission (dashboard Approve by a verified owner or merger, #15136) instead; a label on its own never approves a run. Move the ledger mutations into markDeniedCounted/claim so the once-per-head invariant lives on the ledger type. Document that the default-on sweep needs the App's Actions: Read and write and how it relates to /ok-to-test. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Read at head f868e0a against v5. The docs-currency change requested at 9e1821e is addressed, and the trust-policy rework since that head checks out. Looks correct to me.
What I verified
- Owner admission is now head-bound.
src/pkg/github/workflow_auto_approval.go:246-256readsstagelabels.Record.Admission(head), which returns""unlessAdmittedHead == head(src/pkg/stagelabels/store.go:1757-1763). The only writers are the dashboard Approve (src/pkg/dashboard/api_repo_item_decision.go:211) and the contributor lane after a trusted-merger approval is recorded (src/pkg/github/automerge/automerge_operator_admission.go:52), so a contributor cannot carry an admission onto a later push. This is tighter than #16603's "carries the owner'slgtmadmission" wording — a deliberate and sound narrowing, andruntime-and-quota.md/webhooks.mdnow say so. - Event and head-repo filter sit in the approval decision, not the probe.
workflowRunApprovable(workflow_auto_approval.go:215-231) admits onlypull_requestruns on the exact head SHA and, once the fresh PR read supplies it, the matching head repository;workflowApprovalFromRuns(workflow_approval.go:119) is unchanged apart from retainingruns, so the #16599 caption still counts every gated run. - Once-per-head holds under concurrency.
claim(:124-135) flipsattemptedunder the ledger mutex before the first POST; a partial failure does not reopen the head.touchLocked(:86-104) evicts superseded heads and >24h entries, so the ledger stays bounded. - Default-on + Actions: write is stated as such in #16603 (per #16603:
governor.ci.auto_approve_workflowsdefaulttrue, 403 recorded once and surfaced in the caption), andgithub-app-setup.md:43/46/93andacmm-policy-matrix.md:196-208now document the grant and thefalseescape hatch.
Open question for the owner, not blocking: GitHub treats 404 as the "no actions: write" signal here (:349) — a run that was approved or cancelled between the listing and the POST would also be recorded as permission_error and flip the caption for that head. Rare, and the next push clears it.
— hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
Document why trusting the App as a run's triggering actor cannot approve contributor code: GitHub gates only fork pull_request runs and the App cannot push to a fork, so an App-pushed same-repository branch is never gated. Code comment on workflowApprovalTrusted and the operator reference. The default of governor.ci.auto_approve_workflows stays as #16603 specifies (on); flipping it is the owner's call, not a code defect. Hive-Fix-Attempt: 2/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
There was a problem hiding this comment.
security · delta re-review at aa82bc7 (previous head f868e0a)
Delta is comment/doc text only (src/pkg/github/workflow_auto_approval.go:186-193, src/docs/operator-reference/runtime-and-quota.md:280-285); no behavior change.
Prior findings:
- App as triggering actor trusts the run on contributor code — resolved: the new comment states the argument and I checked it against the code.
workflowRunApprovable(workflow_auto_approval.go:217-219) approves onlypull_requestruns matching the PR head and head repo; GitHub gates only forkpull_requestruns, and an installation token scoped to the base repo cannot push to a fork, so a fork head'striggering_actoris the fork pusher, not the App. The fresh PR re-read before the POST (:323-326) re-binds author/head. governor.ci.auto_approve_workflowsdefault-on — still present, no longer blocking: #16603 specifiesdefault trueand App trust verbatim; the PR body flags the default for owner sign-off and the operator reference documentsfalsefor self-hosted runners.
Advisory (non-blocking): the fork-safety argument assumes the login returned by AppBotLogin() (workflow_auto_approval.go:271) is pushable only by this hive. If the GitHub App is public and a contributor installs it on their fork, pushes from that installation carry the same <slug>[bot] login and would be trusted as "the App" on a fork head. Worth a sentence in the comment ("the App is private to the owner") or a headRepo == base repo check in the actor branch; not required for #16603.
— hive: agent=adjudicator-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Owner decision (@clubanderson): approved as written.
Reviewer cleared correctness; CI is green on d18fb6c. Merging. /approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: clubanderson The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
LGTM label has been added. DetailsGit tree hash: 80e390b8091c1e9c7a1da095fd90afc935c29cd2 |
|
Thank you for your contribution! Your PR has been merged. We'd love to hear how your experience was: share feedback |
Closes #16603
Closes #16682
Closes #16695
Supersedes #16681
Why
Dependabot PR #16567 sat two hours at review-pending because all 11 workflow runs on its head were
action_required. That is GitHub's "Approve and run workflows" gate, and those runs create no check runs. Since #16599 the Activity Monitor names the gate, but nothing moved until a maintainer clicked Approve. For heads the owner already trusts (dependabot/renovate, the hive's own App, or PRs the owner admitted withlgtm), that click adds no information, so the hive now makes it itself.The trust policy and default (
governor.ci.auto_approve_workflowson when unset) are taken as written in #16603. Reviewers on #16681 raised the default-on question for owner sign-off. It still applies here. Operators on self-hosted runners can set the key tofalse, and the operator reference says so.How it stays bounded
ci_rerunwrite-back gate all apply.actions: write) is recorded once and never retried.EnrichCIStatusapplies the ledger on every cycle, soCI waiting · needs workflow approval on GitHubstays visible on cycles that skip the sweep. This addresses the second ✨ feat(ci): approve gated workflows for trusted PR heads #16681 finding.Review findings resolved by construction
workflowRunsAwaitingApprovalis unchanged and has noeventfilter, so the ✨ Activity Monitor chevrons: active-with-text / icon-only spec, CI and review ring glyph, workflow-approval stall caption #16599 detection and caption still count every gated run. Thepull_request-only filter lives in the approval decision (workflowRunApprovable), andTestWorkflowApprovalProbeCountsEveryEventpins this.runtime-and-quota.md,webhooks.md) say the sweep is skipped whenever the API-budget decision setsSkipOptional: conserve/critical mode, off-cadence and cached-snapshot cycles. They do not claim it runs after every enrichment pass.Decision taken by hive: the approval counters live on the
github.Clientthat/api/statusalready reaches throughdeps.GHClient, and onlypull_request-event runs are approved, neverpull_request_target, which runs with repository secrets.— hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@clubanderson