Skip to content

✨ feat: mark lanes unauthorized when the App lacks rights for the next step - #14595

Merged
hivecommons-hive[bot] merged 2 commits into
v5from
feat/unauthorized-pill
Oct 27, 2026
Merged

hivecommons-hive[bot] merged 2 commits into
v5from
feat/unauthorized-pill

Conversation

@clubanderson

Copy link
Copy Markdown
Member

Fixes #14589

What

When a GitHub App API call that is a prerequisite for the lane's progress fails with 403 Resource not accessible by integration, the hive now says so plainly instead of warning every tick and silently waiting:

  • Generic helper markUnauthorized(ctx, repo, pr, head, step, permission, humanAction) / clearUnauthorized in src/pkg/github/automerge/automerge_unauthorized.go: adds hive:unauthorized, posts one idempotent comment per (head, step) (<!-- hive:unauthorized head=<sha> step=<step> -->) naming the exact missing permission and the exact human step, logs once per head at INFO (msg="lane unauthorized"), returns reason unauthorized:<step>.
  • Wired: held-run approval from ✨ feat(automerge): approve held workflow runs for registry-trusted contributors #14520 (approveHeldRunsForRegistryTrusted) — needs actions: write; the comment says to click Approve and run and lists the run ids and the missing required check. Cleared in the same tick the required checks for the head report (no human label edit).
  • Stage engine: unauthorized:* → 085 with the reason kept; the 085 entry comment (decisionCause) names the refused step.
  • Dashboard: unauthorized modifier (label-driven, like stalled/hold/draft), muted pill (dashed, --text-muted), tooltip from payload unauthorized, counted under Needs attention; the 085 cell and caption read Awaiting human: approve workflow runs (payload unauthorized_step). hive:unauthorized joins the needs-human label preset.
  • Other 403 sites (automerge_contributor_adopt.go close-PR, automerge_sweep.go update-branch, automerge_merge_forward.go) are ambiguous (fork editability / rate limit / archived) and carry TODO(hivecommons/hive#14589) comments rather than being wired.
  • Docs: labels-and-control-signals (label lifecycle row), dashboard-sections (pill), github-app-setup (actions: write is optional; without it the hive marks unauthorized and waits). Changelog fragment changelog.d/added-unauthorized-label.md.

Tests

Table-driven, no time.Sleep:

  • TestContributorLaneUnauthorizedWhenApproveForbidden: 403 → label + 1 marker comment + reason set once; second tick same head → no duplicate; checks appear → label removed and state cleared in that tick; restart case (label + marker already present) re-posts nothing.
  • Non-403 approve error (500) → no label, no comment, reason unchanged.
  • TestIsResourceNotAccessible, TestUnauthorizedCommentAndMarker, TestClassifyStageUnauthorizedParksForMaintainer, dashboard modifier/payload/caption tests and a node-run pill/tooltip/gate-word check.

@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Oct 27, 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 clubanderson 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 needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 27, 2026
…t step

A GitHub App API call the contributor lane needs to advance that fails
with 403 Resource not accessible by integration now routes through
markUnauthorized: label hive:unauthorized, one comment per (head, step)
naming the missing permission and the human step, reason
unauthorized:<step> parking the PR at 085, one INFO log per head, and
clearUnauthorized in the tick the step is no longer needed. First call
site: held-run approval without actions: write. Dashboard draws a muted
unauthorized pill and reads Awaiting human: approve workflow runs.

Fixes #14589

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@clubanderson
clubanderson force-pushed the feat/unauthorized-pill branch from a7b2643 to 3b9cd69 Compare October 27, 2026 15:58
@kubestellar-prow kubestellar-prow Bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 27, 2026
@hivecommons-hive hivecommons-hive Bot added author/human A person pushed this PR themselves dco All commits are DCO signed-off stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

@clubanderson is auto-promoted for contributor-lane merging on this PR: the last 5 merged PRs by this author in this hive's repositories have no revert or sentinel-alert evidence. CI, reviewer verdict, diff fences, soak, holds and branch protection still apply.

@hivecommons-hive hivecommons-hive Bot added role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Oct 27, 2026
@hivecommons-hive

Copy link
Copy Markdown
Contributor

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

Failing checks:

  • test (rest 1/4)

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.

@github-actions

github-actions Bot commented Oct 27, 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
#14573 ✨ feat(dashboard): show a draft pill in the activity tracker CONFLICT src/pkg/dashboard/stage_tracker.go
src/pkg/dashboard/static/index.html
#14597 🐛 fix(dashboard): show the fleet running · $/hour figure in the visible Governor grid same files src/pkg/dashboard/static/index.html
#14582 ✨ House-style section every kick opens with: repo HIVE_STYLE.md > hive default > built-in same files src/pkg/dashboard/static/index.html

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Another agent tried to open a PR from scanner/fix-14589, but this PR already closes #14589. No second PR was opened; please continue here, or rebase the new work onto this branch.

Signed-off-by: Andy Anderson <andy@clubanderson.com>
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/071-needs-author Human-authored PR: CI red, changes requested or conflicting; diagnosis posted, the author must act labels Oct 27, 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.

Read at 9792784 against the tree. The core mechanism is sound; one small text/behaviour mismatch worth fixing before merge.

Verified correct

  • The new label cannot block its own lane: labelBlockReason (automerge_sweep.go:1935–1953) only reacts to sentinel / needs-rebase / needs-human / do-not-merge* / hold labels, so hive:unauthorized on the PR does not make approveHeldRunsForRegistryTrusted bail and then clearUnauthorized strip the label on the next tick.
  • Restart path: contributorHeldRunsApprovalAttempted is in-memory, so after a restart the approve is retried and 403s again, but markUnauthorized (automerge_unauthorized.go:118–143) skips the label when pr.Labels already carries it and commentUnauthorized returns on the existing <!-- hive:unauthorized head=… step=… --> marker — no duplicate, as the test asserts.
  • Clear is tied to the step, not the label: automerge_contributor_lane.go:1259–1267 clears whenever the reason stops being unauthorized:* (checks appeared, head moved, or green), and clearUnauthorized (:150–172) leaves a mark for a different step alone.
  • isResourceNotAccessible requires both 403 and the integration body, so rate-limit / archived 403s are not misclassified.

Finding (low) — automerge_unauthorized.go:211: the posted note ends with "this label and note clear themselves", but nothing in the PR deletes or edits the comment (clearUnauthorized only removes the label; no DeleteComment/EditComment anywhere in the diff). The note is also the idempotency marker, so deleting it would be wrong — the fix is the wording: "this label clears itself" (or say the note stays as a record). labels-and-control-signals.md says "pill, label and payload fields clear themselves", which is accurate; only the comment text over-promises.

Not approving (human signature), but with that one line changed I see nothing else blocking.

— hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@github-actions github-actions Bot added the conflicts-with-open-pr Open PR has a merge conflict with another open PR label Oct 27, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit 3cb02a9 into v5 Oct 27, 2026
80 of 81 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the feat/unauthorized-pill branch October 27, 2026 16:48
@hivecommons-hive

Copy link
Copy Markdown
Contributor
Evidence bundle `#145959792784` sha256:c54868ef799f35ad3629bff568c62a09648031763f857f9f16cc579fd9bb0419 — download from the dashboard or `hivectl review evidence #14595`.

@hivecommons-hive

Copy link
Copy Markdown
Contributor

merged by Hive trusted-author auto-merge: author @clubanderson holds role owner and GitHub permission admin on repo; CI green at 9792784.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

We'd love to hear how your experience was: share feedback

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 conflicts-with-open-pr Open PR has a merge conflict with another open PR dco All commits are DCO signed-off 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.

Mark lanes unauthorized when the App lacks rights for the next step (held-run approval 403)

1 participant