Skip to content

✨ PR gate: fail visibly when the Commit statuses grant is missing - #19063

Merged
kubestellar-prow[bot] merged 4 commits into
v5from
feat/pr-gate-grant-visibility
Nov 19, 2026
Merged

kubestellar-prow[bot] merged 4 commits into
v5from
feat/pr-gate-grant-visibility

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Second slice of the hive-posted PR-contents gate: it fails visibly instead of silently. Default off; with auto_merge.pr_gate.mode off or unset nothing changes (no request, no status field, no heartbeat field).

  • Grant check: at startup and every 15 minutes the hive reads the Commit statuses permission its App installation was actually granted (the installation permission map now carries statuses). A missing grant forces the gate off and never promotes it to enforce; a failed read keeps the last known answer.
  • Runtime failure: a 403 on a status write is recorded per repository, counted, and not retried for 15 minutes; it also invalidates the grant read.
  • Spoke: /api/status carries prGate and the dashboard shows a banner naming the installation, what is missing, where an owner accepts it (the App's pending permission request) and the days left before 2026-12-02.
  • Hub: the heartbeat carries the cause and whether a required context depends on the gate; the health verdict is red when the gate cannot be posted and a required context depends on it, amber otherwise, with a remediation hint.
  • Held reason: in enforce mode a missing required gate context shows unauthorized:post-pr-gate-status instead of a bare required-check-missing (enforce itself still runs as shadow in this PR).

Tests are table-driven with recorded fixtures: grant present, missing, read-only, none, token credential; 403 at post time and cooldown; a repo whose required set does not depend on the gate; the red versus amber decision; held reason; banner markup.

Refs #19038

@kubestellar-prow kubestellar-prow Bot added dco-signoff: yes Indicates the PR's author has signed the DCO. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Open PR overlap check

Base branch: v5

Conflicts are checked with every PR merged onto the current tip of v5, so a PR that only needs a rebase is not reported as conflicting with its siblings.

PR Title Relation Files
#19199 ✨ ask: hub backend for optional Ask AI help (phase 1 of #19177) same files src/pkg/hub/server.go
#19143 🐛 Reviewer-stated rules: ignore quotes and questions, match more future phrasings, and give the preferences a Settings card CONFLICT src/docs/api-reference/auth.md (conflict)
src/pkg/dashboard/static/index.html
#19102 🐛 Let the agent that opened a PR reply on its review threads same files src/cmd/hive/main.go

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

UI render evidence

Render evidence captured.

Built from 85c91f37c3eb.
Screenshots: download the artifact (sign-in to GitHub required).
Run: https://github.com/hivecommons/hive/actions/runs/44436822478

Page Section Viewport Theme File Size
hive overview desktop light hive-overview-desktop-light.png 308 KB
hive overview desktop dark hive-overview-desktop-dark.png 306 KB
hive overview phone light hive-overview-phone-light.png 466 KB
hive overview phone dark hive-overview-phone-dark.png 464 KB
hub-fleet overview desktop light hub-fleet-overview-desktop-light.png 113 KB
hub-fleet overview desktop dark hub-fleet-overview-desktop-dark.png 115 KB
hub-fleet overview phone light hub-fleet-overview-phone-light.png 265 KB
hub-fleet overview phone dark hub-fleet-overview-phone-dark.png 270 KB
hub-dashboard overview desktop light hub-dashboard-overview-desktop-light.png 338 KB
hub-dashboard overview desktop dark hub-dashboard-overview-desktop-dark.png 344 KB
hub-dashboard overview phone light hub-dashboard-overview-phone-light.png 624 KB
hub-dashboard overview phone dark hub-dashboard-overview-phone-dark.png 656 KB

These are fixture renders, not live data: the page was built from the PR head and filled with synthetic data from src/scripts/fixtures/render-evidence/. They show layout and theming, not how real hives behave. How to read them: src/docs/ui-render-evidence.md.

@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.

@clubanderson this PR is held at stage/071-needs-author and the hive will not merge it yet.

Why:

  • the review swarm requested changes

Next: the hive does not push to your branch. Push a new head (or reply here); CI and the review swarm re-run automatically and the PR returns to the normal path.

hive/awaiting-ci: rebased onto v5 (only docs-citation conflicts, resolved to the base side and refreshed with check-docs-citations.py --fix). CI pending - sweep will merge when green.


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

@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Mutation testing

⏱️ The 900s mutation budget ran out, so 4 package(s) were not fully mutated and the results below do not cover them:

  • pkg/github: cut short (partial, no report)
  • pkg/hub: skipped (not started)
  • pkg/prgate: skipped (not started)
  • pkg/stageengine/prstage: skipped (not started)

1 mutant(s) in changed files are not reached by any test (NOT COVERED). A maintainer may apply the mutation/acknowledged label to accept this.

File Line Mutation
src/pkg/dashboard/api_pr_gate.go 118 ARITHMETIC_BASE

Verdict: uncovered (#17349).

@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.

Correctness review at a81230e: no blocker found. The grant check, forced-off mode, per-repo 403 cooldown and heartbeat plumbing hang together, and the nil-gate paths return early.

One low advisory, with the detail in the inline comment: the write-refused state is derived from the retry cooldown, so it clears after 15 minutes without a successful post. Tests were not run.

-- hive: agent=adjudicator backend=claude model=claude-sonnet-5-5 claude=2.1.327

Comment thread src/pkg/prgate/grant.go

func (g *Gate) repoForbiddenLocked(repo string) bool {
s := g.stats[strings.ToLower(repo)]
return s != nil && g.Now().Before(s.forbiddenUntil)

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.

forbiddenUntil is both the retry cooldown and the only record that a write was refused. After 15 minutes ForbiddenRepos, Cause=write-refused and HoldReason all go empty with no successful post and no change in the grant. This happens when the grant read says write but the write still gets a 403, and it only comes back on the next event. Advisory fix: set a refused bool in post() on ErrForbidden, clear it only on a successful post, and read it in HealthFor and HoldReason. Keep forbiddenUntil only for the retry gate in HandleEvent.

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 18, 2026
@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 18, 2026

@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.

Correctness review at head d4d8a91. Locking and the off-mode path look sound; one in-scope concern is inline: the new held-reason short-circuit in resolveMissingRequiredCheck can mislabel a missing required context as a grant problem and skip the workflow-approval and orphaned-run diagnosis. Fix: run that diagnosis first and use the grant reason only as the fallback.

-- hive: agent=adjudicator-3 backend=claude model=claude-sonnet-5-5 claude=2.1.327

// by polling: the owner accepts the permission.
missing := strings.TrimPrefix(reason, requiredCheckMissingPrefix)
if held := prgate.DefaultHoldReason(owner+"/"+repo, missing); held != "" {
if c.markTerminalHoldLogged(owner, repo, number, headSHA, prGateHoldWarnKey+missing) {

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.

This returns unauthorized:post-pr-gate-status before the existing workflow-approval / orphaned-run diagnosis. HoldReason only checks configured==enforce and (grant missing or a recent 403), yet enforce still runs as shadow, so the workflow, not the hive, supplies these contexts. A context missing because a run awaits approval or is orphaned would be mislabeled as a grant problem. Suggest running the existing diagnosis first and using the grant reason only as the fallback when it finds nothing.

@hivecommons-hive

hivecommons-hive Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

@clubanderson this PR is back in your court (stage/071-needs-author). Its commits are signed off as the hive App rather than as you, so a squash merge would misattribute them and the sign-off attribution check stays red. No hive agent can rewrite a contributor's commits — the fix is yours:

  • 2 commits are signed off as the hive App instead of you, so a squash merge would misattribute them — set git config user.email to your own address, then run git rebase --exec 'git commit --amend --no-edit --reset-author -s' HEAD~4 && git push --force-with-lease

Once the new head lands, CI and the review swarm re-run automatically and the PR returns to the normal path. Current head: 61edb5a75d6a.

Updates (newest last):

  • updated 2026-11-19 00:43 UTC: head 61edb5a75d6a, 2 commits signed off as the hive App

@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.

Delta re-review at 10dc6ff: the earlier correctness finding at automerge_held_runs.go:146 is still present (hunk unchanged). See the inline thread.

-- hive: agent=adjudicator-5 backend=claude model=claude-sonnet-5-5 claude=2.1.327

// by polling: the owner accepts the permission.
missing := strings.TrimPrefix(reason, requiredCheckMissingPrefix)
if held := prgate.DefaultHoldReason(owner+"/"+repo, missing); held != "" {
if c.markTerminalHoldLogged(owner, repo, number, headSHA, prGateHoldWarnKey+missing) {

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.

Still present from d4d8a91. This early return fires on any missing gate context whenever the grant is missing or the repo was forbidden (prgate/grant.go:222-235), so approval-held or never-started runs get mislabelled unauthorized:post-status and the workflowApprovalAttention/takeover diagnostics below are skipped. Suggest running the run-based diagnostics first and falling back to held only when they find nothing specific (or when len(held)==0).

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 18, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

Baseline triage: native-queue-policy and Sign-off survives the squash are red here, not shared across the default branch, but this branch is behind v5 (siblings #19063, #19102, #17512 are all behind). Suggested fix: merge v5 into the branch (signed off) and re-check before diagnosing further. Not pushed, as this is not a hive-authored branch.


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

@github-actions github-actions Bot removed the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 18, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

hive/awaiting-ci: this branch has a merge conflict with v5 and is behind it, which also explains the Sign-off survives the squash and native-queue-policy failures. Suggested fix: merge v5 in (signed off), resolve the conflict, push. Not pushed, since this is not a hive-authored branch.


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

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Scanner triage: failing checks here are not caused by this diff. Baseline check says MERGE_BASE: the branch is 14 commits behind v5 (sibling PRs are equally stale). Suggested fix: merge v5 into the branch with sign-off (git merge -s ort --signoff origin/v5) and push, then re-check. Not pushed from here because the branch is not hive-authored.


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

The hive-posted PR-contents gate never fails silently.

- Grant check: at startup and every 15 minutes the hive reads the Commit
  statuses permission its App installation was actually granted (the
  installation permission map now carries statuses). A missing grant forces
  the gate off and never promotes it to enforce.
- Runtime failure: a 403 on a status write is recorded per repository,
  counted, and not retried for 15 minutes; it also invalidates the grant read.
- Spoke: /api/status carries prGate and the dashboard shows a banner naming
  the installation, what is missing, where an owner accepts it and the days
  left before 2026-12-02.
- Hub: the heartbeat carries the cause and whether a required context depends
  on the gate; the health verdict goes red then, amber otherwise, with a
  remediation hint.
- Held reason: in enforce mode a missing required gate context shows
  unauthorized:post-pr-gate-status instead of a bare required-check-missing.

Nothing changes while auto_merge.pr_gate.mode is off.

Refs #19038

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
Refs #19038

Signed-off-by: Andrew Anderson <andy@clubanderson.com>
@hivecommons-hive
hivecommons-hive Bot force-pushed the feat/pr-gate-grant-visibility branch from 10dc6ff to 61edb5a Compare November 19, 2026 00:42
@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 19, 2026

@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.

Delta re-review at 61edb5a. The compare against 10dc6ff is 164 files, almost all of it merged mainline work. I read only the PR's own files, mainly automerge_held_runs.go, prgate/gate.go and prgate/grant.go.

Previous finding (held-reason short-circuit, automerge_held_runs.go): still present.
resolveMissingRequiredCheck still returns the unauthorized:post-pr-gate-status reason straight away (automerge_held_runs.go:137-151 in the diff). That return happens before the workflow-run, approval and never-started analysis. Gate.HoldReason only fires when the grant is missing or the repo is in the 403 cooldown, so the grant is a true cause. It is not necessarily the only one. A PR with the grant missing and also a held action_required run, or a never-started head, shows only the grant reason. After the owner accepts the grant, the PR then falls back to bare required-check-missing or a workflow-approval reason, so the hold looks like it reappears.

Requested change: still compute the underlying reason, and return the grant reason only when the underlying one is the bare reason. For example, move the DefaultHoldReason block after the run analysis and apply it only where the function would otherwise return reason.

Rest of the delta in the PR's own files: no new correctness issues found. I did not run the tests, and I did not read the mainline-merge hunks.

-- hive: agent=adjudicator backend=claude model=claude-sonnet-5-5 claude=2.1.327

Signed-off-by: Andy Anderson <andy@clubanderson.com>

# Conflicts:
#	src/docs/api-reference/hub-server.md
Signed-off-by: Andy Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the feat/pr-gate-grant-visibility branch from 61edb5a to 85c91f3 Compare November 19, 2026 01:25
@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Nov 19, 2026
@clubanderson clubanderson added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Nov 19, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

Approval requirements bypassed by manually added approval.

This pull-request has been approved by:

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

The pull request process is described 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 merged commit 781e39d into v5 Nov 19, 2026
99 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/pr-gate-grant-visibility branch November 19, 2026 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. conflicts-with-open-pr Open PR has a merge conflict with another open PR dco-signoff: yes Indicates the PR's author has signed the DCO. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant