Skip to content

πŸ› dashboard: surface Prow's rejection of relayed /lgtm and /approve - #17478

Merged
hivecommons-hive[bot] merged 7 commits into
v5from
scanner/fix-17475
Nov 10, 2026
Merged

hivecommons-hive[bot] merged 7 commits into
v5from
scanner/fix-17475

Conversation

@hivecommons-hive

Copy link
Copy Markdown
Contributor

Closes #17475

Part of #17451 (children #17474 and #17476 remain)

Why

dibs#510 skips relaying /lgtm + /approve only once Prow's rejection is already on the PR. On the first Approve nothing read Prow's reply, so the toast still said approved while Prow answered 'restricted to collaborators' / 'NOT APPROVED' (#17359).

What

  • After posting the commands, reportOperatorPullRequestApproval reads the PR comments for Prow's reply (polling ~6s on Prow-managed PRs, one read otherwise) and sets PullRequestApprovalEvent.ProwRejected.
  • The row action result / response (prow_rejected) says Prow rejected the commands and an OWNERS reviewer is needed, instead of 'Approved'.
  • Persistence: Prow's reply is a durable PR comment, so the next Approve takes the existing prow-rejects-bot-commands skip path.
  • Tests: github (reply after post) and dashboard (result wording). Additive only.

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88 requested_by=@clubanderson

Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Nov 9, 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 the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 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
#17479 πŸ› prow: post /ok-to-test once on admitted non-member fork PRs same files src/pkg/github/pr_decision_operator.go
src/pkg/github/pr_decision_operator_test.go

@hivecommons-hive

hivecommons-hive Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor Author

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: scanner | Instance: hosted-available-oke-11-placeholder-r05x | SHA: unknown

β€” hive: agent=scanner backend=copilot model=claude-fable-5.1 copilot=1.0.88

Review findings from reviewer (folded here because this head already carries its hive review):

Read the diff against the v5 tree and the callers; this looks correct to me.

  • src/pkg/github/pr_decision_operator.go:121-139 β€” awaitProwRejection reuses prowRejectedHiveCommands (:151), so the post-hoc read keeps the existing guards: only config.DefaultLabelDrivenTrustedBots logins count, and the reply must quote #issuecomment-<id> of a hive command comment (Review backlog (security): Third-party bot reply can suppress /lgtm + /approve posting (still present, fail-safe)Β #15263). No new trust surface.
  • The 6s poll window sits inside defaultApprovalReportingTimeout (15s, :471), and the loop returns on ctx.Done(); on cancellation reportOperatorPullRequestApproval still returns ctx.Err() (:516) so the existing ReportingError path is unchanged.
  • Non-Prow repos get one extra comment list per Approve (wait=false); read errors are swallowed to false, so a GitHub blip cannot turn a successful post into a spurious "rejected".
  • Wording flows through RowActionResult (api_repo_item_decision.go:899-944); nothing in the UI reads commands_skipped/prow_rejected directly, so prow_rejected is additive and CommandsSkipped keeps precedence in the Posted line.
  • TestRecordOperatorPullRequestApprovalReportsProwRejectionAfterPost shrinks the window to 1s/10ms and covers both the rejected and silent cases; the fake server's first POST id (9001) matches the own comment the reply quotes.

Body matches the diff (read the body after the code). Docs paragraph in activity-monitor.md:491 describes the new toast accurately.

Review findings from reviewer-2 (folded here because this head already carries its hive review):

Read the diff against src/pkg/github/pr_decision_operator.go and the dashboard handler at the PR head (eb139e6). Looks correct to me.

What I verified

  • awaitProwRejection (pr_decision_operator.go:121-139) reuses prowRejectedHiveCommands, which only counts a reply from a config.DefaultLabelDrivenTrustedBots login that quotes one of the hive's own #issuecomment-<id> (:151-199). Since the pre-post check at :496 returned false on the same thread, any rejection found after the post is necessarily Prow's answer to the comments just posted β€” no stale-reply false positive.
  • The poll is bounded by prowReplyWindow (6s) and by ctx, which RecordOperatorPullRequestApprovalWith caps at defaultApprovalReportingTimeout (15s, :449-470); the delegated and queue-merge callers use the same 15s budget, so the wait fits inside the existing reporting window.
  • Dashboard wiring: ProwRejected flows event β†’ repoItemApproveFacts β†’ repoItemApproveResult, and the new else if at api_repo_item_decision.go:919 is unreachable when CommandsSkipped is set, so the two wordings cannot both appear. Docs paragraph in activity-monitor.md matches the code's headline/Posted text.

Two non-blocking notes (info)

  1. Every dashboard Approve on a Prow-managed PR now takes up to ~6s longer on the HTTP request path (handlePullRequestDecision awaits the event synchronously). That is a deliberate trade and is documented in the PR body; just flagging it for the maintainer so the slower toast isn't mistaken for a hang.
  2. With wait=false (non-Prow repos) awaitProwRejection still does one listIssueComments immediately after the post (:124). Prow can't have replied yet on a repo that has no Prow, so this is one extra API call per approval that will essentially always return false. Harmless; could be skipped by guarding the call with event.ProwManaged instead of passing it as wait.

No conflict with #17479: it touches the same file but only exports prowManagedLabels; the hunks are disjoint.

Evidence bundle `#17478eb139e6` sha256:f5d2c9eb2b9bfb04b75b8a43f4f2c9dd8e821548b5dd9b4ebb311f62fa8717da β€” download from the dashboard or `hivectl review evidence #17478`.

@hivecommons-hive hivecommons-hive Bot added author/hive This repository's own hive (the App or one of its agent lanes) authored this PR dco All commits are DCO signed-off 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 labels Nov 9, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Looks correct to me; the operator docs describe only the second-Approve path and should pick up the first-Approve one this adds.

Verified against the tree (v5 merge-base):

  • awaitProwRejection (src/pkg/github/pr_decision_operator.go:121) reuses prowRejectedHiveCommands, which already requires the Prow reply to quote one of the hive's own command comments by #issuecomment-<id> and come from a DefaultLabelDrivenTrustedBots login (pr_decision_operator.go:146-192). So the new read cannot be satisfied by an unrelated or spoofed comment β€” the #15263 guard carries over unchanged.
  • event.ProwManaged is set from prowManagedLabels(labels) at construction (pr_decision_operator.go:422), before reportOperatorPullRequestApproval runs, so the wait flag is meaningful when it is consulted at line 509.
  • The poll is bounded by prowReplyWindow and by ctx, and it runs inside the existing 15s defaultApprovalReportingTimeout context, so the worst case on a Prow repo is ~4-6s added to the Approve request, not an unbounded hang. (Polls fire at t=0, 2, 4s; the last iteration stops once now+interval would pass the 6s deadline, so the effective window is 4s β€” fine, just noting it is a bit shorter than the variable name suggests.)
  • Dashboard wording: repoItemApproveResult (src/pkg/dashboard/api_repo_item_decision.go:899-944) now routes ProwRejected through the same "recorded in hive" headline and OWNERS-reviewer Next as Prow/CommandsSkipped, and the Posted branch distinguishes "posted, but Prow rejected" from "not posted". The new test asserts exactly that.

Docs (low): src/docs/dashboard-sections/activity-monitor.md:491 explains the skip path (commands_skipped: prow-rejects-bot-commands, toast not posted) but says nothing about the first Approve: the new prow_rejected response field and the posted, but Prow rejected them wording. A sentence next to that paragraph would keep the operator doc in step with the response shape.

Not a defect, just a note: the v5..head diff also shows CHANGELOG.md losing 12 lines and four other fragments reappearing β€” that is the branch being behind v5's changelog compile, not a change in this PR (gh pr diff shows 6 files). A rebase before merge clears it.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 10, 2026
Review follow-ups for #17478:

- activity-monitor.md now describes the first-Approve path: the commands
  are posted, Prow's rejection is awaited, and the response carries
  `prow_rejected: true` with the "posted, but Prow rejected them" toast,
  before the later `commands_skipped` path.
- awaitProwRejection sleeps min(interval, remaining) so the last read
  lands at the end of prowReplyWindow instead of stopping one interval
  short (polls at 0/2/4/6s rather than 0/2/4s).

Hive-Fix-Attempt: 1/6
Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com>

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against src/pkg/github/pr_decision_operator.go and src/pkg/dashboard/api_repo_item_decision.go. Looks correct to me.

What I verified:

  • Ordering is right: the pre-existing prowRejectedHiveCommands read at pr_decision_operator.go:496 still decides the skip path before posting; awaitProwRejection (:514) runs only on the post branch and re-lists comments, so the own set it matches against includes the two comments just posted. The match still requires Prow's #issuecomment-<id>) back-reference and a DefaultLabelDrivenTrustedBots author (:163-195), so the #15263 guard against a third-party bot faking the phrase is intact.
  • The ≀6 s poll fits inside the existing 15 s defaultApprovalReportingTimeout (:470); on cancellation awaitProwRejection returns false and return ctx.Err() surfaces it as ReportingError with the native approval still recorded β€” same contract as before.
  • Toast wording is server-side: the frontend does not read commands_skipped/prow_rejected (only api_repo_item_decision.go references them), and repoItemApproveResult now branches on ProwRejected for headline, Posted, and the OWNERS note (:902, :919, :941). The CommandsSkipped branch is checked first, so the two never both print.
  • activity-monitor.md:491 updated to describe the first-Approve behaviour; changelog fragment present.

One optional note, not a defect: with event.ProwManaged == false the call at :514 still does a single extra listIssueComments round-trip on every non-Prow Approve, immediately after the one at :496. It is harmless (and a safety net if Prow detection misses), just worth knowing it is there.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/080-awaiting-merge-admission CI green, verdict approve, no modifiers; the automerge lane has not admitted it yet and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head labels Nov 10, 2026
@hivecommons-hive hivecommons-hive Bot added stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/080-awaiting-merge-admission CI green, verdict approve, no modifiers; the automerge lane has not admitted it yet labels Nov 10, 2026

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read pr_decision_operator.go around the new awaitProwRejection and the existing prowRejectedHiveCommands (pr_decision_operator.go:151-199), plus repoItemApproveResult. The mechanism is sound: the pre-post check at :496 already returns CommandsSkipped whenever a bound Prow rejection exists, so any rejection awaitProwRejection finds after posting is necessarily a reply to the comments just posted (the detector only counts a Prow-bot reply quoting #issuecomment-<id> of a hive command comment). The wait is bounded by the request ctx and prowReplyWindow, and ReportingError handling is unchanged. The wording change in the dashboard is tested. Looks correct to me.

Two notes, non-blocking:

  1. Scope vs #17475. The issue asks to "persist the rejection so later approvals on the same repo take the CommandsSkipped path". What ships persists per PR (Prow's reply comment on that PR); the first Approve on every new PR in the repo still posts both commands and draws a fresh rejection. That is a reasonable place to stop, but with Closes #17475 the body should say the repo-level memory was not done (or the issue should stay open for it).
  2. awaitProwRejection(…, wait=false) (pr_decision_operator.go:514) still does one listIssueComments immediately after the post on non-Prow PRs. Prow answers via webhook a second or more later, so that read can essentially never observe a reply and is an extra API call on every non-Prow approval. Skipping it when !event.ProwManaged would be cheaper with no loss.

β€” hive: agent=reviewer-2 backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against src/pkg/github/pr_decision_operator.go and src/pkg/dashboard/api_repo_item_decision.go at 04d63da. Looks correct to me.

What I verified:

  • reportOperatorPullRequestApproval (pr_decision_operator.go:496-514) still does the pre-post prowRejectedHiveCommands read, so the second Approve takes the existing prow-rejects-bot-commands skip path exactly as before; the new awaitProwRejection only runs in the branch that actually posted the commands.
  • prowRejectedHiveCommands (:151-199) only counts a reply from config.DefaultLabelDrivenTrustedBots that quotes a hive command comment by #issuecomment-<id>, so a rejection detected inside the window is bound to the comments just posted β€” the test's replyAfterPost fixture mirrors that (issue_unpark_command_test.go:212-216).
  • awaitProwRejection returns on ctx.Done() and reportOperatorPullRequestApproval already folds ctx.Err() into ReportingError, so a cancelled request leaves the native approval recorded, as today.
  • Dashboard wiring: ProwRejected flows event β†’ repoItemApproveFacts β†’ repoItemApproveResult (api_repo_item_decision.go:899-942); the CommandsSkipped/ProwRejected else if ordering means a second Approve keeps the "not posted" wording rather than claiming a fresh rejection.

One observation, not a defect: on a Prow repo where the hive bot is an approver, Prow's positive reply does not match prowCommandRejections, so every Approve now spends the full prowReplyWindow (6 s) before the toast appears β€” the happy path pays the latency, not just the misconfigured one. If that matters, matching Prow's acknowledgement (approved label applied / LGTM added) as an early exit would bound it. The queue-merge decision (api_repo_item_decision.go:621) goes through the same call and inherits the wait too, though it never surfaces prow_rejected.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against v5 plus the callers; this looks correct to me.

  • src/pkg/github/pr_decision_operator.go:514 β€” awaitProwRejection runs only on the post path (the prowRejected pre-check at :497 still routes to CommandsSkipped), and event.ProwManaged is set at construction (:427, prowManagedLabels(labels)), so the polling branch is reachable when intended and the single-read branch covers non-Prow PRs.
  • Budget: prowReplyWindow (6s) sits inside defaultApprovalReportingTimeout (15s, :471). If the earlier label/stage calls ever eat more than ~9s the wait ends on ctx.Done() and the trailing return ctx.Err() at :516 surfaces as ReportingError β€” that is the pre-existing contract, just noting the window now consumes part of it.
  • src/pkg/dashboard/api_repo_item_decision.go:899-944 β€” the three ProwRejected branches (headline, Posted, Next) are consistent with the CommandsSkipped wording, and TestRepoItemApproveResultSurfacesProwRejection pins them.
  • The replyAfterPost hook in issue_unpark_command_test.go:212 makes the comment listing reflect the post, so the "prow rejects" / "prow silent" cases exercise the real poll loop rather than a stub.

Docs (activity-monitor.md) and the changelog fragment match the behaviour. Nothing blocking from me.

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Read the diff against v5 plus the callers; this looks correct to me.

What I verified

  • src/pkg/github/pr_decision_operator.go:514 β€” awaitProwRejection runs only on the post path, after both commands were created, and reuses prowRejectedHiveCommands (:151), which already requires the reply to be from a DefaultLabelDrivenTrustedBots login and to quote a hive command comment id, so the new flag cannot be set by an arbitrary commenter.
  • The wait is bounded: prowReplyWindow (6s) sits inside defaultApprovalReportingTimeout (15s, :470), and the loop selects on ctx.Done(), so a cancelled request still returns ctx.Err() as before.
  • src/pkg/dashboard/api_repo_item_decision.go:899-944 β€” ProwRejected changes the headline, the Posted line and the Next note; CommandsSkipped keeps precedence in the Posted branch, which matches the two states being mutually exclusive in the client (:496-514).
  • The fake server change in issue_unpark_command_test.go:212 lets the reply appear only after the POST, so the "prow silent" case genuinely exercises the full window rather than a pre-seeded comment.
  • No overlap with #17479's edit to the same file (that PR only exports prowManagedLabels at :481); the hunks are far apart.

One observation, not a defect

  • On a Prow-managed PR where Prow accepts the commands (or answers late), the dashboard Approve request now blocks for the full 6s before returning, since awaitProwRejection only exits early on a rejection. That is within the existing timeout and probably acceptable for a human-initiated action; noting it so the latency is not a surprise.

Body and diff agree (prow_rejected, polling only when ProwManaged, changelog + activity-monitor doc updated).

β€” hive: agent=reviewer backend=copilot model=claude-fable-5.1 copilot=1.0.88

@hivecommons-hive hivecommons-hive Bot added stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it stage/050-review-pending Review swarm requested; awaiting a verdict for the current head and removed stage/050-review-pending Review swarm requested; awaiting a verdict for the current head stage/070-fixing Hive-authored PR: CI red, changes requested or needs rebase; a hive agent is fixing it labels Nov 10, 2026
@hivecommons-hive
hivecommons-hive Bot merged commit b5d366d into v5 Nov 10, 2026
91 of 97 checks passed
@kubestellar-prow
kubestellar-prow Bot deleted the scanner/fix-17475 branch November 10, 2026 01:48
@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/hive This repository's own hive (the App or one of its agent lanes) authored this PR copilot dco All commits are DCO signed-off dco-signoff: yes Indicates the PR's author has signed the DCO. role/trusted Author is trusted for unattended merge (trusted-author role or registry/claim tier in require_tiers) size/L Denotes a PR that changes 100-499 lines, ignoring generated files. stage/050-review-pending Review swarm requested; awaiting a verdict for the current head

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scanner] πŸ› dashboard: surface Prow's rejection of relayed /lgtm /approve instead of showing approved

0 participants