Skip to content

🐛 Post the PR-contents merge check from the hive itself so it no longer depends on a pull_request_target workflow #19038

Open

Description

@clubanderson

Summary

GitHub will block pull_request_target workflows by default in public repositories from 2026-12-02 unless an Actions event policy allows them. The required check verify PR contents currently comes from a pull_request_target workflow (.github/workflows/pr-verifier.yml). Once the event is blocked the check never reports, so PRs park as required-check-missing and auto-merge stops. Customers must not have to change settings in their own repositories, so the hive should post this check itself as a commit status.

Where it applies

New package src/pkg/prgate (name open), the existing authenticated pull_request webhook handling (src/pkg/dashboard/api_github_webhook.go, src/pkg/github/webhook_ci_evidence.go), the existing commit-status writer used for the Prow lgtm status (src/pkg/github/client.go, with its permission-missing handling), the governor cycle for a backstop sweep, and src/pkg/github/merge_ci_gate.go.

What exists today

  • The verdict logic is a PR title and body check (prTypeVerdict, prIssueVerdict in integration-governance.cjs, used by pr-verifier.cjs). The verify PR contents job stays green by design and records the verdict in the PR Type and PR Issue check runs.
  • The merge lanes read required checks by name only (EvaluateCommitCI in src/pkg/github/commit_ci.go), so a commit status with the same context name satisfies a required context just like a check run.
  • The Hive Apps already document an optional commit-status write grant.

What we need

  1. A Go port of the verdict logic with a shared golden corpus that is run against both the Go and the JS implementations so they cannot drift.
  2. A poster that publishes commit statuses on the exact PR head SHA for these contexts only: verify PR contents, PR Type, PR Issue, and verify PR contents (hive) (shadow name). A hard allowlist in code, with a test that fails if any other context (in particular DCO or any other required context) could be posted.
  3. Triggers: the existing pull_request webhook events (opened, edited, synchronize, reopened, ready_for_review, labeled, unlabeled) plus a governor backstop sweep that posts for any open PR head that has no gate status (missed webhooks, restarts, github.token autofix pushes). Pin the head SHA from the event, re-read the PR head before posting, skip draft and closed PRs.
  4. Config auto_merge.pr_gate.mode: off | shadow | enforce, default off, explicit repo scope. In shadow the hive posts only verify PR contents (hive) (and advisory statuses under shadow names where they would collide) and logs a comparison against the workflow result. In enforce it posts the real names. A startup self-check of the installation's granted permissions forces off and raises a dashboard banner when commit-status write is missing.
  5. Change the agent merge-request watcher so zero-job startup_failure runs of event pull_request_target do not turn the verdict RED when the required context set is known and all required contexts are green (log them instead). This protects repositories that never touch their workflows.
  6. Docs (src/docs, including the GitHub App setup doc and the L6 guide), a changelog fragment, and tests with recorded API fixtures, no live GitHub.

Acceptance criteria

  • With the mode off nothing changes. In shadow the shadow status appears on real PR heads and the comparison log shows agreement with the workflow result.
  • A status posted by the hive satisfies a required context of the same name in the existing merge lanes (tested).
  • The allowlist test proves no other context can be posted.
  • The permission self-check turns the feature off and shows the banner when the grant is missing.
  • No change in behavior for repositories where the mode is off.

Open questions

  • Whether a status can be posted on a fork PR head with the base installation token. A canary on a test repository settles this before enforcement.
  • How the hive identifies its own status (creator login) when installations use differently named Apps; a repository variable is proposed (see the companion issue for the gate script).

Detecting a missing App grant and failing visibly (required)

The feature must never fail silently when the Hive App on an installation has not been granted commit-status write (installations keep their old permissions until an owner accepts the change, which can go unnoticed). Required behavior:

  1. Grant check. At startup and on a TTL, read the installation's granted permissions (the existing installation permission map in src/pkg/github/app.go and the grant logging in src/pkg/apphealth) and compare with what the feature needs. Missing grant: force the mode to off, and never auto-promote to enforce.
  2. Runtime failure check. A 403 or other refusal when posting a status is recorded per repository (reuse the existing handling that classifies it as github_app_statuses_permission_missing) and counted. Do not retry in a loop.
  3. Visible on the spoke. A dashboard banner modeled on the existing GitHub App permission banner (src/pkg/dashboard/static-src/js/banners.js) that names the installation, says what is missing and where an owner accepts it (the App's pending permission request in the org settings), and, before the cutoff date, how many days remain.
  4. Visible on the hub. A health verdict cause with a remediation hint in the existing hive health system (src/pkg/hub/health_verdict.go, src/pkg/hub/remediation.go) so My Hives and the fleet view show it. It must turn red when the gate cannot be posted AND a required context depends on it (merges would stall), amber otherwise.
  5. Escalation. After the cutoff date, if the grant is still missing and the required context is absent on recent heads, raise the existing fleet-report class (github_app_statuses_permission_missing) so it is filed and not just shown.
  6. No silent stall. In enforce mode, if a status cannot be posted for a PR head, the PR must show a clear reason (for example a held reason naming the missing grant) instead of a bare required-check-missing.
  7. Tests. Table tests with recorded fixtures for: grant present, grant missing, 403 at post time, a repo whose required context does not depend on the gate, and the red versus amber decision.

Activity

  1. self-assigned this
    on Nov 18, 2026
  2. clubanderson commented on Nov 18, 2026

    @clubanderson
    MemberAuthor

    Claimed by the maintainer: a dispatched agent is working this, one PR to follow. Please do not open a parallel PR.

  3. hivecommons-hive commented on Nov 18, 2026

    @hivecommons-hive
    Contributor

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

    PR #19287 covers this issue: #19287

    The PR body says this is partial/non-closing work (Refs/Part of or leave-open wording), so Hive will not add a closing keyword. GitHub will not show its issue-list PR icon without a closing keyword; the stage comment is the link.

  4. 11 remaining items

  5. added
    hive/partially-addressedA merged PR addressed only part of this issue; remainder still actionable
    stage/010-actionableTriaged; eligible for the hive to pick up
    and removed on Nov 19, 2026
  6. github-actions commented on Nov 19, 2026

    @github-actions
    Contributor

    PR #19063 has merged (#19063) and referenced this issue with a non-closing Refs #19038 rather than a closing keyword.

    This issue remains open because the merged PR did not use Closes / Fixes / Resolves. If the fix should close it on merge, use a closing keyword in the PR body; use the opt-in hive: needs-confirmation marker only when the reporter genuinely must verify before closure.

  7. clubanderson commented on Nov 19, 2026

    @clubanderson
    MemberAuthor

    Remaining work split into child issues, one PR each: #19284 (enforce mode), #19285 (backstop sweep), #19286 (fork-head canary). Retiring the workflow stays in #19040.

  8. clubanderson commented on Nov 19, 2026

    @clubanderson
    MemberAuthor

    PRs for the remaining scope: #19287 (enforce mode, fixes #19284), #19293 (backstop sweep, fixes #19285), #19295 (fork-head canary, fixes #19286). Read-only evidence for the fork question: fork PR #19255 head 05faf9a already carries a prow/lgtm commit status created by hivecommons-hive[bot] with the base installation token, through the same writer the gate uses. Nothing was switched live: hivecommons/hive stays at its current pr_gate mode until an operator follows the steps in #19287's docs.

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

Metadata

Metadata

Assignees

Labels

hive/partially-addressedA merged PR addressed only part of this issue; remainder still actionablestage/010-actionableTriaged; eligible for the hive to pick upstage/stalledIn its current stage longer than expected

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions