From ed22f02cf8193a061547e7811206b79d1f40d0e5 Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 28 Oct 2026 21:13:23 -0400 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=90=9B=20sentinel:=20remember=20a=20d?= =?UTF-8?q?ashboard=20Approve=20as=20the=20release=20of=20that=20head;=20s?= =?UTF-8?q?kip=20Prow-rejected=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A dashboard Approve takes the sentinel label off as the hive's own account, so sentinelClearedAfterLatestPush (rightly) did not read the unlabeled event as a human clearance and the sweep re-alerted the head the owner had just approved (dibs#510, 00:32Z approved → 00:33Z re-labelled). The sweep now reads the hive's own hive:pr-approval head= command comment as the release for exactly that head and rewrites its marker comment as the released alert, as the #13602 path does; a new push re-arms. On a Prow repo where the bot is not an approver, a later Approve records the decision without re-posting /lgtm + /approve and reports commands_skipped. Fixes #15214 Signed-off-by: Andrew Anderson --- changelog.d/fixed-sentinel-release-memory.md | 1 + src/docs/dashboard-sections.md | 2 +- src/docs/operator-reference.md | 7 ++ src/pkg/dashboard/api_repo_item_decision.go | 26 ++++- .../automerge_contributor_lane_test.go | 46 ++++++++ src/pkg/github/pr_decision_operator.go | 91 ++++++++++++++-- src/pkg/github/pr_decision_operator_test.go | 48 ++++++++ src/pkg/github/sentinel_clearance.go | 47 +++++++- src/pkg/github/sentinel_sweep.go | 14 ++- src/pkg/github/sentinel_sweep_test.go | 103 ++++++++++++++++++ 10 files changed, 365 insertions(+), 20 deletions(-) create mode 100644 changelog.d/fixed-sentinel-release-memory.md diff --git a/changelog.d/fixed-sentinel-release-memory.md b/changelog.d/fixed-sentinel-release-memory.md new file mode 100644 index 0000000000..8c1b5e0036 --- /dev/null +++ b/changelog.d/fixed-sentinel-release-memory.md @@ -0,0 +1 @@ +- Sentinel: a dashboard Approve on a flagged PR is now remembered as the release of that head — the sweep reads the hive's own `hive:pr-approval head=` comment instead of treating the hive-account `unlabeled` event as nobody's clearance, so it no longer re-posts the alert and re-applies `sentinel-alert` to the head the owner just approved (dibs#510, hivecommons/hive#15214); a new push still re-arms. On a Prow repo where the bot is not an approver, a later Approve records the decision without re-posting `/lgtm` + `/approve` and reports `commands_skipped`. diff --git a/src/docs/dashboard-sections.md b/src/docs/dashboard-sections.md index deb29e3b25..b3115731e1 100644 --- a/src/docs/dashboard-sections.md +++ b/src/docs/dashboard-sections.md @@ -704,7 +704,7 @@ Fed by `GET /api/stage-tracker`. Every issue and pull request follows the same p **Legend — the three cues a row may carry** (shared with the in-flight and needs-human work landing beside this): the *state pill* says where the item is and what it is waiting on (`hold`, `needs human`, `stage ↓` …); the *working* spin on the lit chevron says the hive is doing something in that stage right now (a still chevron = waiting on something, its tooltip says what); the *decision badge* (the history mark with its count) says a person acted here and what followed. Plain words throughout — working / waiting on X / set back by Y / merged — nothing else blinks. -**Row actions (right-click, ⋯, Shift+F10).** Right-clicking a row — or a nested PR sub-row — opens an in-app context menu of the actions that fit that item's current state; the ⋯ button in the row's left gutter (every nested PR sub-row has its own gutter with its own checkbox and ⋯) opens the same menu for pointer-free use, and so do **Shift+F10** and the context-menu key while the row or anything in it has focus (every row is a tab stop). The menu is positioned at the pointer, clamped to the viewport, uses `menu` / `menuitem` roles, moves focus with ↑ ↓ Home End, opens the *Decide…* group with → and closes it with ←, and closes on Esc, Tab, click-away, scroll or resize, returning focus to the row. Shift+right-click keeps the browser's own menu. Entries, each shown only when it applies: **Decide…** on a row waiting on a person — a PR wearing the *Needs human decision* pill at 085 on the Merge gate column (the primary case: e.g. two competing `dibs` PRs), an issue row whose one nested PR is parked there (the menu reads *Decide PR #458…* and acts on that PR, since the issue's own stage is only mirrored from it), or an issue parked at 045. **PR-scoped actions on nested PRs** ([#15009](https://github.com/hivecommons/hive/issues/15009): one issue, two PRs — [#15017](https://github.com/hivecommons/hive/pull/15017) *Ready for human merge · untrusted author* and [#15020](https://github.com/hivecommons/hive/pull/15020) *Needs human decision* — and no way to decide one without the other): every nested PR sub-row carries its own ⋯ menu, and its *Decide…* (Let hive decide, Approve, Close as superseded by…, Won't fix…, Give direction…), *Hold* / *Release hold* and the rest act on **that PR** — `runRowAction(action, row)` receives the PR's own row object (number, repo, head), never the parent issue's, and the needs-human popover opened from a sub-row's chevron does the same. A PR waiting for a person to merge it (*Ready for human merge*, a `human_merge_reason` such as an untrusted author) counts as parked for this purpose. When an issue has two or more open nested PRs the issue row's menu no longer offers a single *Decide…* that would silently pick one: it offers **Let hive decide — all N PRs** (hint *per PR*), which asks the server to decide each PR on its own (see [Let hive decide](#let-hive-decide)); the issue's own *Decide…* stays only when the issue itself is parked at 045. *Close as superseded by…* on a nested PR with exactly one open sibling under the same issue pre-fills that sibling's number. The first entry is always *Let hive decide* (see [Let hive decide](#let-hive-decide) below): the hive decides as the owner's delegate and records it the way a person's decision is recorded. For a PR: *Approve (/lgtm + /approve)* posts those two commands as comments attributed to you and records your approval against the PR's current head as the human answer the row was parked for — a `requires_human` / decision-requested reviewer verdict, the hive's own `needs-human` park (a supersession question, say), the `sentinel-alert` label and the evidence bundle's sentinel findings are all released by it (the response's `released` lists what was: `approval-recorded`, `needs-human`, `sentinel-label`, `sentinel-acknowledged`), the stage engine re-derives the stage on the spot and the tracker cache is dropped, so the row leaves *Needs human decision* for 080 *Awaiting merge admission* on the next read; the merge gate (and the auto-merge lanes, which honour the recorded approval on that head exactly as a trusted merger's GitHub Approve review) takes it from there; the dashboard never reviews as you and never merges. A new head carries no answer: pushing to the PR re-asks. The delegated *Let hive decide* path still posts the comments only — it recommends and never clears a sentinel alert — *Close as superseded by…* (a picker listing the other open PRs in the repo, or type `#458` / `owner/repo#458` / a URL; then an optional comment, then the sweep's labelled close), *Won't fix…* (a comment naming you, then a not-planned close) and *Give direction…* (your text is recorded as `/hive decision ` against the head, so the author agent pushes a new head; only on PRs the hive opened). For an issue: *Approve direction* (records the same `/hive approve` a maintainer would comment: the parking labels come off, `approved-direction` goes on, the stage engine logs the un-park and a reply comment names you; nothing is merged), *Send back to the hive…* (`/hive decision `), *Close as superseded by…* and *Close as won't-fix…*. A selection mixing parked issues and parked PRs has Decide… greyed; **Hold** or **Release hold** depending on the `hold` chip (the same `…/items/{number}/hold` toggle as the repository cards, and the same permission — owner, or a signed-in user with write access to the repo); **Re-evaluate now** (the hive-wide read-only rescan behind the Overview's refresh — a rescan already running is reported, not duplicated); **Accept triage** (only on an issue the chevron calls *Triage needed* — stage 015, or the `needs-triage` chip on another stage — never on a PR; the one-click form of a maintainer accepting triage on GitHub: adds the reporter-trust triage label, `triage/accepted` by default or the first of `issue_filter.reporter_trust.untrusted_require_labels`, removes the awaiting label `needs-triage` / `reporter_trust.awaiting_label` and a Hive-written `stage/015-triage-needed`; the row re-reads *Actionable* with the 👤 gone at once, the reporter-trust gate admits the issue on its next poll and the stage engine records 015 → 010; same permission as Hold, audited as `repo_item_accept_triage`, a no-op when already accepted); **Mark needs-human…** (hidden once the chip is on; merger or owner role, applies `needs-human` and a marker comment through the review pipeline's send-to-human endpoint); **Open on GitHub**; **Copy link**. Entries you may not use are greyed with the reason in their tooltip, never hidden. Confirmation and free-text input use the dashboard's own dialogs — no browser prompts. Every action is an existing audited dashboard endpoint (the decision endpoint is `POST /api/repos/{owner}/{repo}/items/{number}/decision` and triage acceptance is `POST /api/repos/{owner}/{repo}/items/{number}/accept-triage`, see [api-reference.md](api-reference.md)); none of them bypasses the hive's governance or merges anything. +**Row actions (right-click, ⋯, Shift+F10).** Right-clicking a row — or a nested PR sub-row — opens an in-app context menu of the actions that fit that item's current state; the ⋯ button in the row's left gutter (every nested PR sub-row has its own gutter with its own checkbox and ⋯) opens the same menu for pointer-free use, and so do **Shift+F10** and the context-menu key while the row or anything in it has focus (every row is a tab stop). The menu is positioned at the pointer, clamped to the viewport, uses `menu` / `menuitem` roles, moves focus with ↑ ↓ Home End, opens the *Decide…* group with → and closes it with ←, and closes on Esc, Tab, click-away, scroll or resize, returning focus to the row. Shift+right-click keeps the browser's own menu. Entries, each shown only when it applies: **Decide…** on a row waiting on a person — a PR wearing the *Needs human decision* pill at 085 on the Merge gate column (the primary case: e.g. two competing `dibs` PRs), an issue row whose one nested PR is parked there (the menu reads *Decide PR #458…* and acts on that PR, since the issue's own stage is only mirrored from it), or an issue parked at 045. **PR-scoped actions on nested PRs** ([#15009](https://github.com/hivecommons/hive/issues/15009): one issue, two PRs — [#15017](https://github.com/hivecommons/hive/pull/15017) *Ready for human merge · untrusted author* and [#15020](https://github.com/hivecommons/hive/pull/15020) *Needs human decision* — and no way to decide one without the other): every nested PR sub-row carries its own ⋯ menu, and its *Decide…* (Let hive decide, Approve, Close as superseded by…, Won't fix…, Give direction…), *Hold* / *Release hold* and the rest act on **that PR** — `runRowAction(action, row)` receives the PR's own row object (number, repo, head), never the parent issue's, and the needs-human popover opened from a sub-row's chevron does the same. A PR waiting for a person to merge it (*Ready for human merge*, a `human_merge_reason` such as an untrusted author) counts as parked for this purpose. When an issue has two or more open nested PRs the issue row's menu no longer offers a single *Decide…* that would silently pick one: it offers **Let hive decide — all N PRs** (hint *per PR*), which asks the server to decide each PR on its own (see [Let hive decide](#let-hive-decide)); the issue's own *Decide…* stays only when the issue itself is parked at 045. *Close as superseded by…* on a nested PR with exactly one open sibling under the same issue pre-fills that sibling's number. The first entry is always *Let hive decide* (see [Let hive decide](#let-hive-decide) below): the hive decides as the owner's delegate and records it the way a person's decision is recorded. For a PR: *Approve (/lgtm + /approve)* posts those two commands as comments attributed to you and records your approval against the PR's current head as the human answer the row was parked for — a `requires_human` / decision-requested reviewer verdict, the hive's own `needs-human` park (a supersession question, say), the `sentinel-alert` label and the evidence bundle's sentinel findings are all released by it (the response's `released` lists what was: `approval-recorded`, `needs-human`, `sentinel-label`, `sentinel-acknowledged`), the stage engine re-derives the stage on the spot and the tracker cache is dropped — and the sentinel sweep honours the release for that head, re-arming only on a new push — so the row leaves *Needs human decision* for 080 *Awaiting merge admission* on the next read; the merge gate (and the auto-merge lanes, which honour the recorded approval on that head exactly as a trusted merger's GitHub Approve review) takes it from there; the dashboard never reviews as you and never merges. On a Prow repo where the hive bot is not an approver, Prow has already answered the hive's earlier commands with "restricted to collaborators" / "NOT APPROVED"; a later Approve then records the decision without posting the two comments again and says so (`commands_skipped: prow-rejects-bot-commands`, and the toast reads *Approval recorded; `/lgtm` + `/approve` not posted*). A new head carries no answer: pushing to the PR re-asks. The delegated *Let hive decide* path still posts the comments only — it recommends and never clears a sentinel alert — *Close as superseded by…* (a picker listing the other open PRs in the repo, or type `#458` / `owner/repo#458` / a URL; then an optional comment, then the sweep's labelled close), *Won't fix…* (a comment naming you, then a not-planned close) and *Give direction…* (your text is recorded as `/hive decision ` against the head, so the author agent pushes a new head; only on PRs the hive opened). For an issue: *Approve direction* (records the same `/hive approve` a maintainer would comment: the parking labels come off, `approved-direction` goes on, the stage engine logs the un-park and a reply comment names you; nothing is merged), *Send back to the hive…* (`/hive decision `), *Close as superseded by…* and *Close as won't-fix…*. A selection mixing parked issues and parked PRs has Decide… greyed; **Hold** or **Release hold** depending on the `hold` chip (the same `…/items/{number}/hold` toggle as the repository cards, and the same permission — owner, or a signed-in user with write access to the repo); **Re-evaluate now** (the hive-wide read-only rescan behind the Overview's refresh — a rescan already running is reported, not duplicated); **Accept triage** (only on an issue the chevron calls *Triage needed* — stage 015, or the `needs-triage` chip on another stage — never on a PR; the one-click form of a maintainer accepting triage on GitHub: adds the reporter-trust triage label, `triage/accepted` by default or the first of `issue_filter.reporter_trust.untrusted_require_labels`, removes the awaiting label `needs-triage` / `reporter_trust.awaiting_label` and a Hive-written `stage/015-triage-needed`; the row re-reads *Actionable* with the 👤 gone at once, the reporter-trust gate admits the issue on its next poll and the stage engine records 015 → 010; same permission as Hold, audited as `repo_item_accept_triage`, a no-op when already accepted); **Mark needs-human…** (hidden once the chip is on; merger or owner role, applies `needs-human` and a marker comment through the review pipeline's send-to-human endpoint); **Open on GitHub**; **Copy link**. Entries you may not use are greyed with the reason in their tooltip, never hidden. Confirmation and free-text input use the dashboard's own dialogs — no browser prompts. Every action is an existing audited dashboard endpoint (the decision endpoint is `POST /api/repos/{owner}/{repo}/items/{number}/decision` and triage acceptance is `POST /api/repos/{owner}/{repo}/items/{number}/accept-triage`, see [api-reference.md](api-reference.md)); none of them bypasses the hive's governance or merges anything. **What a row tells you without a click (`tracker-cues`).** The owner's framing (2026-10-28): "Hive is doing the right things mostly; we now need to keep the user informed of it — like a video game they can watch and see what happens easily." Every row therefore reads, in this order, *where it is → whether work is happening on it → what it waits on → what just happened*, with at most three cue types drawing the eye and nothing else blinking. **Where it is** is the lit chevron (the state pill). **Working** — the chevron's icon turns slowly and the pill pulses only while a hive agent is actually on the item right now (the status payload's `agents[].lastAction` for the current round, matched to the row or to the PR shown on its row); its tooltip then leads with *Working now: scout commented · 2m ago —* before the stage words. A still chevron means **waiting**; its tooltip already says where it stands and whose move it is (*Needs decision — … · Next move: human*). **Acting** — from the moment you choose a row action the affected row (and the nested PR sub-row when the action targets it) draws faint stripes over its lit chevron and an *Approving… / Hive is deciding… / Holding…* caption with a small spinner; it clears when the tracker reports the target in a new state, at once on a no-op or an error, and never later than three minutes. **Event line** — one short plain sentence under the strip about the latest thing that happened to the row, from the difference between two tracker payloads (the poll / SSE refetch the tracker already makes; no extra requests): *Hive: moved to CI / Review · 12s ago*, *Hive: fell back to Claimed — a reviewer requested changes* (a lower stage number reads as a fall only when the stage table's `falls_to` — the stage engine's regression rule — says so; triage accepted 015 → 010, a decision made 085 → 080 or the author resuming 072 → 070 read *moved to*), *Hive: waiting on a person*, *Hive: hold released*, *You: approved*. It lives two minutes, dims for its last third, and a row carries only its latest line. **Set back** — a row wearing `regressed` colours the line's lead red. **Merged** — see *Merged (the chip, the ledger, the flight)* below. The CSS class names are shared so the sibling Activity Monitor PRs (needs-human options, decision trail) compose on them: `cue-working`, `cue-acting`, `cue-event`, `cue-setback`, `cue-merged`, `cue-decision` (badge, sibling PR), `cue-spin` (the one spin keyframe), `cue-flight` / `ham-merged-count` (the glyph and the Merged chip); the colour tokens `--cue-state`, `--cue-work`, `--cue-decision` on `.ham-row` are declared in the *Cue tokens* paragraph under [Let hive decide](#let-hive-decide) below. Legend, in the operator's words: **working** (icon turns), **waiting on X** (still; tooltip names X), **set back by Y** (red lead on the event line), **merged** (✓ glows, a bee rises to the Merged chip or off the top of the screen). Under `prefers-reduced-motion: reduce` every cue animation stops; the words stay. diff --git a/src/docs/operator-reference.md b/src/docs/operator-reference.md index 281dfbc57a..9d4c96e9cc 100644 --- a/src/docs/operator-reference.md +++ b/src/docs/operator-reference.md @@ -944,6 +944,13 @@ into blocking them. A maintainer who removes the label keeps the PR clear until the author pushes again: the sweep reads the clearance back from the alert comment it left for that head (alert comment present, label absent), so it survives a hub restart or a second replica and nothing else needs to be posted. +A dashboard **Approve** is the same clearance for the head it names: the hive +takes the label off as its own account, so the `unlabeled` event alone is not +read as a human clearance; the `/lgtm` + `/approve` comments the approval +posted carry a `hive:pr-approval head=` marker, and the sweep reads that +as the release for exactly that head (rewriting its alert comment to say so), +so it does not re-apply the label the owner just released (dibs#510). A later +push re-arms it. | Behavior | Fires when | |---|---| diff --git a/src/pkg/dashboard/api_repo_item_decision.go b/src/pkg/dashboard/api_repo_item_decision.go index 36533506cd..8685500dfd 100644 --- a/src/pkg/dashboard/api_repo_item_decision.go +++ b/src/pkg/dashboard/api_repo_item_decision.go @@ -175,6 +175,11 @@ type repoItemDecisionResponse struct { // contributor lane merges the head as-is and the adoption engine // leaves the PR alone (hivecommons/hive#15136). AdmittedBy string `json:"admitted_by,omitempty"` + // CommandsSkipped is set when an Approve did not post the `/lgtm` + + // `/approve` comments: "prow-rejects-bot-commands" on a Prow repo where + // the hive bot is not an approver, so they would only draw another + // "NOT APPROVED" (dibs#510). The approval itself is still recorded. + CommandsSkipped string `json:"commands_skipped,omitempty"` } // admitPullRequestHead records user's Approve as the trust override for @@ -211,6 +216,10 @@ type repoItemApproveFacts struct { // came from the hive's account, which is not in OWNERS, so Prow ignores // it and the toast must not claim the PR is approved for Prow. Prow bool + // CommandsSkipped: the `/lgtm` + `/approve` comments were not posted + // because Prow already rejected the hive's commands on this PR + // (dibs#510); the hive's own approval record is what counts. + CommandsSkipped bool } // repoItemDecisionResult reads a recorded human decision into the shared @@ -587,7 +596,7 @@ func (s *Server) handlePullRequestDecision(ctx context.Context, w http.ResponseW err error ) var released []string - stage := "" + stage, commandsSkipped := "", "" sentinelOpen, prow := false, false if decision == repoItemDecisionApprove { var event ghpkg.PullRequestApprovalEvent @@ -598,6 +607,7 @@ func (s *Server) handlePullRequestDecision(ctx context.Context, w http.ResponseW }) head = event.HeadSHA released, stage, sentinelOpen, prow = repoItemApprovalReleased(event), event.Stage, event.SentinelLabelOpen, event.ProwManaged + commandsSkipped = event.CommandsSkipped } else { var event ghpkg.PullRequestDecisionEvent event, err = gh.RecordOperatorPullRequestDecision(ctx, repoFull, number, user, comment, repoItemDecisionChangeRequests()) @@ -632,13 +642,13 @@ func (s *Server) handlePullRequestDecision(ctx context.Context, w http.ResponseW released = append(released, "admitted") } } - s.audit.LogRecord(user, action, auditDetail("repo", repoFull, "number", numStr, "type", "pr", "head", head, "decision", comment, "released", strings.Join(released, ","), "stage", stage, "admitted_by", admitted), "", repoFull, number) + s.audit.LogRecord(user, action, auditDetail("repo", repoFull, "number", numStr, "type", "pr", "head", head, "decision", comment, "released", strings.Join(released, ","), "stage", stage, "admitted_by", admitted, "commands_skipped", commandsSkipped), "", repoFull, number) // The row's park was just answered: serve the re-derived stage on the // next tracker read instead of the cached 085. s.invalidateStageTrackerForWebhook() - jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: status, Released: released, Stage: stage, Head: head, AdmittedBy: admitted, + jsonResponse(w, repoItemDecisionResponse{OK: true, Repo: repoFull, Number: number, Decision: decision, Status: status, Released: released, Stage: stage, Head: head, AdmittedBy: admitted, CommandsSkipped: commandsSkipped, Result: repoItemDecisionResultWith(repoFull, number, "pr", decision, comment, "", "", repoItemApproveFacts{ - User: user, Released: released, Stage: stage, SentinelOpen: sentinelOpen, SentinelLabel: s.sentinelLabel(), SoakMinutes: s.approveSoakMinutes(admitted != ""), Prow: prow, + User: user, Released: released, Stage: stage, SentinelOpen: sentinelOpen, SentinelLabel: s.sentinelLabel(), SoakMinutes: s.approveSoakMinutes(admitted != ""), Prow: prow, CommandsSkipped: commandsSkipped != "", })}) } @@ -688,7 +698,11 @@ func repoItemApproveResult(out *RowActionResult, number int, facts repoItemAppro headline += " · sentinel alert still open" } out.Outcome = headline + "." - out.Posted = append(out.Posted, "`/lgtm` posted", "`/approve` posted") + if facts.CommandsSkipped { + out.Posted = append(out.Posted, "`/lgtm` + `/approve` not posted (Prow does not accept the hive bot's commands on this repo)") + } else { + out.Posted = append(out.Posted, "`/lgtm` posted", "`/approve` posted") + } if released["needs-human"] { out.Posted = append(out.Posted, "`needs-human` label removed") } @@ -706,7 +720,7 @@ func repoItemApproveResult(out *RowActionResult, number int, facts repoItemAppro default: out.Next = "Hive's merge sweep merges it on its next pass once CI is green and the head has soaked" + repoItemSoakNote(facts.SoakMinutes) + "." } - if facts.Prow { + if facts.Prow || facts.CommandsSkipped { // Prow reads `/approve` only from OWNERS; the hive's account is not // one, so the relayed command is "NOT APPROVED" there. out.Next = "Prow approval still needs an OWNERS reviewer: the relayed `/approve` came from hive's account, which Prow does not count. " + out.Next diff --git a/src/pkg/github/automerge/automerge_contributor_lane_test.go b/src/pkg/github/automerge/automerge_contributor_lane_test.go index 38a368408b..18bda101d9 100644 --- a/src/pkg/github/automerge/automerge_contributor_lane_test.go +++ b/src/pkg/github/automerge/automerge_contributor_lane_test.go @@ -21,6 +21,7 @@ import ( "github.com/hivecommons/hive/pkg/authorkind" hgithub "github.com/hivecommons/hive/pkg/github" "github.com/hivecommons/hive/pkg/intent" + "github.com/hivecommons/hive/pkg/review" "github.com/hivecommons/hive/pkg/stagelabels" ) @@ -783,6 +784,51 @@ func TestTrySweepContributorLaneTrustedHumanApprovalClearsRequiresHuman(t *testi } } +// An owner's dashboard Approve admits the untrusted-author head +// (hivecommons/hive#15136) once the sentinel it released stays released: +// the recorded approval by a trusted merger admits the newcomer-tier claim +// the lane would otherwise refuse, and the PR merges. While the alert label +// is back on the PR — the sentinel re-applying it undid the approval on +// dibs#510 — the lane still stands down with sentinel-blocked, so the label +// memory, not the admission, is what the owner's approval depends on. +func TestTrySweepContributorLaneOperatorApprovalAdmitsReleasedSentinel(t *testing.T) { + for _, tt := range []struct { + name string + labels []string + wantReason string + wantMerges int + }{ + {name: "sentinel released", labels: []string{"stage/085-needs-decision"}, wantMerges: 1}, + {name: "sentinel re-applied", labels: []string{"stage/085-needs-decision", "hive-sentinel"}, wantReason: contributorLaneReasonSentinelBlocked}, + } { + t.Run(tt.name, func(t *testing.T) { + fx := validContributorFixture() + fx.labels = tt.labels + fx.issueComments[0]["body"] = contributorClaimMarkerTier(contributorLaneTestAuthor, "contributor", contributorLaneTestHive, " tier=newcomer verified=true") + api := newContributorLaneAPI(t, &fx) + defer api.Close() + policy := defaultContributorLanePolicy() + clock := &contributorLaneClock{at: time.Date(2026, 10, 15, 13, 0, 0, 0, time.UTC)} + store := review.NewHumanChangeRequests("") + if err := store.Record(review.HumanChangeRequest{Repo: "acme/widget", Number: 7, HeadSHA: "sha7", Actor: "clubanderson", Kind: review.HumanChangeRequestKindApprove, Source: review.HumanChangeRequestSourceDecision, SourceID: 1}); err != nil { + t.Fatal(err) + } + engine := newContributorLaneEngine(api.URL, policy, clock, Options{ContributorSoak: soakedTracker(clock), HumanChangeRequests: store}) + engine.SetMergerAuthorizer(func(login string) bool { return strings.EqualFold(login, "clubanderson") }) + event, reason, err := engine.trySweepContributorLanePR(context.Background(), "widget", "acme", "widget", 7, policy) + if err != nil { + t.Fatal(err) + } + if reason != tt.wantReason || fx.merges != tt.wantMerges { + t.Fatalf("reason=%q merges=%d, want %q/%d", reason, fx.merges, tt.wantReason, tt.wantMerges) + } + if tt.wantMerges == 1 && (!strings.Contains(fx.lastComment, "operator-approval:clubanderson") || event.Number != 7) { + t.Fatalf("merge comment must name the admission: %q (event %+v)", fx.lastComment, event) + } + }) + } +} + // registryTiers returns a ContributorRegistryTierFunc over a fixed // login→tier map (case-insensitive on login), standing in for the // contributor registry on the hive's PVC. diff --git a/src/pkg/github/pr_decision_operator.go b/src/pkg/github/pr_decision_operator.go index bdce03cbb5..392121aa26 100644 --- a/src/pkg/github/pr_decision_operator.go +++ b/src/pkg/github/pr_decision_operator.go @@ -79,6 +79,72 @@ type PullRequestApprovalEvent struct { // Stage is the stage label the engine derived when the approval was // submitted to it, or "" when the stage write was deferred to the sweep. Stage string + // CommandsSkipped is set when the `/lgtm` + `/approve` comments were + // not posted: PRApprovalCommandsSkippedProw when Prow rejected the + // hive's own earlier commands on this PR (the bot is not in OWNERS), + // so posting again would only draw the same "NOT APPROVED" reply. The + // hive's own approval record is unaffected. + CommandsSkipped string +} + +// PRApprovalCommandsSkippedProw is the CommandsSkipped reason for a Prow +// repo where the hive bot is not an approver. +const PRApprovalCommandsSkippedProw = "prow-rejects-bot-commands" + +// prowCommandRejections are the phrases Prow replies with when the hive +// bot's `/lgtm` or `/approve` carries no weight on the repo. +var prowCommandRejections = []string{"restricted to collaborators", "NOT APPROVED"} + +// prowRejectedHiveCommands reports whether a bot other than the hive has +// replied to one of the hive's earlier dashboard approval commands on the +// PR with a Prow rejection (dibs#510: `/lgtm` → "changing LGTM is +// restricted to collaborators", `/approve` → "[APPROVALNOTIFIER] This PR is +// NOT APPROVED"). Prow quotes the comment it answers as +// "In response to [this](…#issuecomment-)", so only replies bound to a +// hive command comment count. +func (c *Client) prowRejectedHiveCommands(ctx context.Context, owner, name string, number int) (bool, error) { + comments, err := c.listIssueComments(ctx, owner, name, number) + if err != nil { + return false, err + } + own := map[int64]bool{} + for _, comment := range comments { + if comment == nil || !c.markerAuthorTrusted(comment.GetUser()) { + continue + } + if _, _, _, ok := ParsePRApprovalCommandComment(comment.GetBody()); ok { + own[comment.GetID()] = true + } + } + if len(own) == 0 { + return false, nil + } + for _, comment := range comments { + if comment == nil || c.isHiveAccount(comment.GetUser()) { + continue + } + login := strings.ToLower(comment.GetUser().GetLogin()) + if !strings.EqualFold(comment.GetUser().GetType(), "Bot") && !strings.HasSuffix(login, "[bot]") { + continue + } + body := comment.GetBody() + rejected := false + for _, phrase := range prowCommandRejections { + if strings.Contains(body, phrase) { + rejected = true + break + } + } + if !rejected { + continue + } + for id := range own { + if strings.Contains(body, fmt.Sprintf("#issuecomment-%d)", id)) { + return true, nil + } + } + } + return false, nil } // PullRequestApprovalOptions is what a person's Approve decision releases @@ -250,14 +316,25 @@ func (c *Client) RecordOperatorPullRequestApprovalWith(ctx context.Context, repo return PullRequestApprovalEvent{}, err } full := owner + "/" + name - for _, command := range PRApprovalCommands { - if err := c.CreateIssueComment(ctx, full, number, renderPRApprovalCommandComment(command, actor, head)); err != nil { - return PullRequestApprovalEvent{}, fmt.Errorf("posting %s on %s/%s#%d: %w", command, owner, name, number, err) - } - } event := PullRequestApprovalEvent{Repo: full, Number: number, HeadSHA: head, Actor: actor, ProwManaged: prowManagedLabels(labels)} - if c.logger != nil { - c.logger.Info("pull request approval commands posted by dashboard decision", "repo", event.Repo, "pr", number, "actor", actor, "head", head) + prowRejected, err := c.prowRejectedHiveCommands(ctx, owner, name, number) + if err != nil { + return PullRequestApprovalEvent{}, fmt.Errorf("reading comments of %s/%s#%d before posting approval commands: %w", owner, name, number, err) + } + if prowRejected { + event.CommandsSkipped = PRApprovalCommandsSkippedProw + if c.logger != nil { + c.logger.Info("pull request approval commands not posted: Prow rejected the hive's earlier commands on this PR (bot is not an approver); the hive's own approval record stands", "repo", event.Repo, "pr", number, "actor", actor, "head", head) + } + } else { + for _, command := range PRApprovalCommands { + if err := c.CreateIssueComment(ctx, full, number, renderPRApprovalCommandComment(command, actor, head)); err != nil { + return PullRequestApprovalEvent{}, fmt.Errorf("posting %s on %s/%s#%d: %w", command, owner, name, number, err) + } + } + if c.logger != nil { + c.logger.Info("pull request approval commands posted by dashboard decision", "repo", event.Repo, "pr", number, "actor", actor, "head", head) + } } if opts.HumanChangeRequests != nil && head != "" { req := review.HumanChangeRequest{ diff --git a/src/pkg/github/pr_decision_operator_test.go b/src/pkg/github/pr_decision_operator_test.go index 8dc594d0b1..51a007af5c 100644 --- a/src/pkg/github/pr_decision_operator_test.go +++ b/src/pkg/github/pr_decision_operator_test.go @@ -3,6 +3,7 @@ package github import ( "context" "errors" + "strconv" "strings" "testing" "time" @@ -241,3 +242,50 @@ func TestRecordOperatorPullRequestApprovalWithoutOptionsStaysCommentsOnly(t *tes t.Fatalf("bare approval touched labels or the stage engine: removed=%v", rec.removed[liveDecisionPR]) } } + +// On a Prow repo where the hive bot is not an approver, the relayed +// commands only draw "changing LGTM is restricted to collaborators" and +// "[APPROVALNOTIFIER] This PR is NOT APPROVED" (dibs#510). Once Prow has +// answered the hive's own commands that way, a later Approve records the +// decision without posting them again and says so on the event; a Prow +// reply to someone else's comment, or no reply at all, changes nothing. +func TestRecordOperatorPullRequestApprovalSkipsCommandsProwRejected(t *testing.T) { + ownLGTM := unparkWireComment{ID: 501, Body: renderPRApprovalCommandComment("/lgtm", "clubanderson", liveDecisionHead), User: wireUser{Login: "hive[bot]"}} + ownApprove := unparkWireComment{ID: 502, Body: renderPRApprovalCommandComment("/approve", "clubanderson", liveDecisionHead), User: wireUser{Login: "hive[bot]"}} + prowReply := func(id int64, text string) unparkWireComment { + return unparkWireComment{ID: 600 + id, Body: text + "\n\n
\n\nIn response to [this](https://github.com/org/repo/pull/1#issuecomment-" + strconv.FormatInt(id, 10) + "):\n\n>/lgtm\n
", User: wireUser{Login: "kubestellar-prow[bot]"}} + } + for _, tc := range []struct { + name string + comments []unparkWireComment + skipped string + }{ + {"lgtm restricted", []unparkWireComment{ownLGTM, prowReply(501, "@hive[bot]: changing LGTM is restricted to collaborators")}, PRApprovalCommandsSkippedProw}, + {"approve not approved", []unparkWireComment{ownApprove, prowReply(502, "[APPROVALNOTIFIER] This PR is **NOT APPROVED**")}, PRApprovalCommandsSkippedProw}, + {"prow answered someone else", []unparkWireComment{ownLGTM, prowReply(77, "@eve: changing LGTM is restricted to collaborators")}, ""}, + {"human quoting the phrase", []unparkWireComment{ownLGTM, {ID: 700, Body: "NOT APPROVED, see #issuecomment-501)", User: wireUser{Login: "eve"}}}, ""}, + {"no prior commands", nil, ""}, + } { + t.Run(tc.name, func(t *testing.T) { + c, rec := newUnparkPRClient(t, []unparkWireIssue{hiveParkedPR(tc.comments...)}, map[string]string{"clubanderson": "admin"}) + store := review.NewHumanChangeRequests("") + event, err := c.RecordOperatorPullRequestApprovalWith(context.Background(), "org/repo", liveDecisionPR, "clubanderson", PullRequestApprovalOptions{HumanChangeRequests: store}) + if err != nil { + t.Fatalf("approval: %v", err) + } + if event.CommandsSkipped != tc.skipped || !event.Recorded { + t.Fatalf("event = %+v, want CommandsSkipped %q and the approval recorded", event, tc.skipped) + } + wantPosted := len(PRApprovalCommands) + if tc.skipped != "" { + wantPosted = 0 + } + if got := rec.posted[liveDecisionPR]; len(got) != wantPosted { + t.Fatalf("posted %d command comments, want %d: %v", len(got), wantPosted, got) + } + if review.HumanApprovalFor(store, "org/repo", liveDecisionPR, liveDecisionHead) == nil { + t.Fatal("the approval must be recorded against the head whether or not the commands were posted") + } + }) + } +} diff --git a/src/pkg/github/sentinel_clearance.go b/src/pkg/github/sentinel_clearance.go index bb54b256ce..e64b519903 100644 --- a/src/pkg/github/sentinel_clearance.go +++ b/src/pkg/github/sentinel_clearance.go @@ -14,6 +14,10 @@ import ( // arguments are the login that removed the label and the label name. const sentinelClearedNote = "_@%s removed the `%s` label after this head was pushed, so Hive treats this head as reviewed and will not re-apply the label unless new commits are pushed._" +// sentinelReleasedNote is the same closing line for a release made by a +// dashboard Approve bound to this head. +const sentinelReleasedNote = "_@%s approved this head from the Hive dashboard, so Hive treats it as reviewed and will not re-apply the `%s` label unless new commits are pushed._" + // sentinelClearedAfterLatestPush reports whether the newest label event for // label on the PR is an `unlabeled` by a human who is not one of the hive's // own accounts, and whether it happened after head was pushed. @@ -94,6 +98,39 @@ func (c *Client) sentinelClearedAfterLatestPush(ctx context.Context, owner, repo return true, actor, nil } +// sentinelReleasedByDashboardApproval reports the login on whose behalf the +// hive posted a dashboard approval command bound to head +// (renderPRApprovalCommandComment), or "" when no such comment exists. +// +// A dashboard Approve takes the alert label off as the hive's own account, +// so sentinelClearedAfterLatestPush rightly refuses to read the `unlabeled` +// event as a human clearance — and the sweep then re-alerted the head the +// owner had just approved (dibs#510: approved 00:32Z, re-labelled 00:33Z). +// The approval comment is the durable, hive-authored record of that +// release: its marker names the head the person saw, so it is never +// honoured on a later push. Only comments the hive itself wrote count; +// anyone can type the marker. +func (c *Client) sentinelReleasedByDashboardApproval(ctx context.Context, owner, repo string, number int, head string) (string, error) { + head = strings.ToLower(strings.TrimSpace(head)) + if head == "" { + return "", nil + } + comments, err := c.listIssueComments(ctx, owner, repo, number) + if err != nil { + return "", fmt.Errorf("listing comments of %s/%s#%d for sentinel release: %w", owner, repo, number, err) + } + for _, comment := range comments { + if comment == nil || !c.markerAuthorTrusted(comment.GetUser()) { + continue + } + _, actor, boundHead, ok := ParsePRApprovalCommandComment(comment.GetBody()) + if ok && boundHead == head && actor != "" { + return actor, nil + } + } + return "", nil +} + // sentinelHeadArrivedAt returns the earliest server-stamped created_at of // a check suite or commit status for sha, which GitHub records when the SHA // first reaches the repository; zero when the SHA has neither. @@ -142,13 +179,15 @@ func (c *Client) sentinelHeadArrivedAt(ctx context.Context, owner, repo, sha str } // recordSentinelClearance makes a clearance accepted by -// sentinelClearedAfterLatestPush durable: the hive's newest marker comment -// on the PR is rewritten as the alert for the current head, in the form +// sentinelClearedAfterLatestPush or sentinelReleasedByDashboardApproval +// durable: the hive's newest marker comment on the PR is rewritten as the +// alert for the current head followed by note (sentinelClearedNote or +// sentinelReleasedNote, already formatted), in the form // sentinelClearedByMaintainer reads back, so a hub restart (empty // sentinelHeads) finds "alert for this head, label absent" and stays quiet. // When the hive has no marker comment on the PR one is posted. -func (c *Client) recordSentinelClearance(ctx context.Context, owner, repo string, number int, label, clearedBy, alert string) error { - body := alert + "\n" + fmt.Sprintf(sentinelClearedNote, clearedBy, label) + "\n" +func (c *Client) recordSentinelClearance(ctx context.Context, owner, repo string, number int, note, alert string) error { + body := alert + "\n" + note + "\n" comments, err := c.listIssueComments(ctx, owner, repo, number) if err != nil { return fmt.Errorf("listing comments for sentinel clearance: %w", err) diff --git a/src/pkg/github/sentinel_sweep.go b/src/pkg/github/sentinel_sweep.go index 6c1912b977..f92031ed3b 100644 --- a/src/pkg/github/sentinel_sweep.go +++ b/src/pkg/github/sentinel_sweep.go @@ -440,13 +440,23 @@ func (c *Client) trySentinelPR(ctx context.Context, displayRepo, owner, repo str // maintainer's review, and the maintainer removed the label with // this head already in place. The second case is a clearance of // this head, not of the one the marker names (#13602); re-alerting - // would make the maintainer remove the same label twice. + // would make the maintainer remove the same label twice. A + // dashboard Approve bound to this head is the same clearance made + // through the hive, which took the label off as itself. cleared, clearedBy, err := c.sentinelClearedAfterLatestPush(ctx, owner, repo, number, head, label) if err != nil { return SentinelSweepEvent{}, false, err } + note := fmt.Sprintf(sentinelClearedNote, clearedBy, label) + if !cleared { + releasedBy, err := c.sentinelReleasedByDashboardApproval(ctx, owner, repo, number, head) + if err != nil { + return SentinelSweepEvent{}, false, err + } + cleared, note = releasedBy != "", fmt.Sprintf(sentinelReleasedNote, releasedBy, label) + } if cleared { - if err := c.recordSentinelClearance(ctx, owner, repo, number, label, clearedBy, SentinelComment(decision, head, author, findings)); err != nil { + if err := c.recordSentinelClearance(ctx, owner, repo, number, note, SentinelComment(decision, head, author, findings)); err != nil { return SentinelSweepEvent{}, false, err } return SentinelSweepEvent{}, false, nil diff --git a/src/pkg/github/sentinel_sweep_test.go b/src/pkg/github/sentinel_sweep_test.go index 8bc4b0ba73..0f856af8fc 100644 --- a/src/pkg/github/sentinel_sweep_test.go +++ b/src/pkg/github/sentinel_sweep_test.go @@ -549,6 +549,109 @@ func TestSweepSentinelClearanceOnNewerHeadIsHonoured(t *testing.T) { } } +// A dashboard Approve releases the head it names (dibs#510): the alert and +// marker are for head A, the PR moves to head B without a fresh alert (the +// label from A still blocks it), and the owner approves B from the +// dashboard, which takes the label off as the hive's own account and posts +// the `/lgtm` + `/approve` comments bound to B. The `unlabeled` event is by +// a hive account and so is not a human clearance on its own; the approval +// comment is. The sweep must stay quiet for B across restarts, rewrite the +// marker as the released alert for B, and still re-alert on a later push. +func TestSweepSentinelDashboardApprovalReleasesHead(t *testing.T) { + alertA := SentinelComment(DecideSentinelAction("sentinel-alert", SentinelAuthorTrust{}, false), "hA", "eve", []sentinel.Finding{{Rule: "sensitive_path", Summary: "workflows", Paths: []string{".github/workflows/ci.yml"}}}) + approvals := func(head string) []string { + var out []string + for _, command := range PRApprovalCommands { + out = append(out, renderPRApprovalCommandComment(command, "clubanderson", head)) + } + return out + } + timeline := []map[string]any{ + sentinelTimelineLabel("labeled", "hive[bot]", "Bot", "2026-10-28T23:30:22Z"), + sentinelTimelineCommit("hB", "2026-10-28T23:55:54Z"), + sentinelTimelineLabel("unlabeled", "hive[bot]", "Bot", "2026-10-29T00:32:07Z"), + } + f := &sentinelFixture{ + prs: []map[string]any{sentinelPR(9, "eve", "hB")}, + files: map[int][]map[string]any{9: {{"filename": ".github/workflows/ci.yml", "status": "modified"}}}, + labelExists: true, + comments: map[int][]string{9: append([]string{alertA}, approvals("hB")...)}, + commentUsers: map[int][]string{9: {"hive[bot]", "hive[bot]", "hive[bot]"}}, + timeline: map[int][]map[string]any{9: timeline}, + checkSuites: map[string][]string{"hB": {"2026-10-28T23:56:00Z"}}, + } + srv := newSentinelServer(t, f) + defer srv.Close() + for pass := 0; pass < 2; pass++ { + c := newTestClient(t, srv, "o", []string{"o/r"}) + c.SetAppBotLogin("hive[bot]") + res, err := c.SweepSentinel(context.Background(), defaultSentinelOpts(nil)) + if err != nil || len(res.Flagged) != 0 || res.Skipped != 1 { + t.Fatalf("pass %d: dashboard-approved head must stay quiet: res=%+v err=%v", pass, res, err) + } + if got := f.labels[9]; len(got) != 0 { + t.Fatalf("pass %d: label re-applied after the owner approved this head: %v", pass, got) + } + if len(f.comments[9]) != 3 { + t.Fatalf("pass %d: no new alert comment may be posted: %d comments", pass, len(f.comments[9])) + } + if body := f.comments[9][0]; !strings.Contains(body, SentinelMarker+" hB") || !strings.Contains(body, sentinelAlertHeading) || !strings.Contains(body, "@clubanderson approved this head from the Hive dashboard") { + t.Fatalf("pass %d: marker comment must be rewritten as the released alert for hB: %q", pass, body) + } + } + + // New commits re-arm: the approval named hB, not hC. + f.mu.Lock() + f.prs[0] = sentinelPR(9, "eve", "hC") + f.checkSuites["hC"] = []string{"2026-10-29T01:00:00Z"} + f.mu.Unlock() + c := newTestClient(t, srv, "o", []string{"o/r"}) + c.SetAppBotLogin("hive[bot]") + res, err := c.SweepSentinel(context.Background(), defaultSentinelOpts(nil)) + if err != nil || len(res.Flagged) != 1 || len(f.labels[9]) != 1 || len(f.comments[9]) != 4 || !strings.Contains(f.comments[9][3], SentinelMarker+" hC") { + t.Fatalf("push after the approval must re-alert: res=%+v err=%v labels=%v comments=%d", res, err, f.labels[9], len(f.comments[9])) + } +} + +// An approval comment releases nothing unless the hive wrote it for this +// head: a forged one by the PR author and the hive's own approval of an +// earlier head both leave the new head alerted on and labelled. +func TestSweepSentinelDashboardApprovalNotHonoured(t *testing.T) { + alertA := SentinelComment(DecideSentinelAction("sentinel-alert", SentinelAuthorTrust{}, false), "hA", "eve", []sentinel.Finding{{Rule: "sensitive_path", Summary: "OWNERS", Paths: []string{"OWNERS"}}}) + approval := func(head string) string { return renderPRApprovalCommandComment("/approve", "clubanderson", head) } + for _, tc := range []struct { + name string + body string + author string + }{ + {"forged by the author", approval("hB"), "eve"}, + {"hive approval of an earlier head", approval("hA"), "hive[bot]"}, + } { + t.Run(tc.name, func(t *testing.T) { + f := &sentinelFixture{ + prs: []map[string]any{sentinelPR(9, "eve", "hB")}, + files: map[int][]map[string]any{9: {{"filename": "OWNERS", "status": "modified"}}}, + labelExists: true, + comments: map[int][]string{9: {alertA, tc.body}}, + commentUsers: map[int][]string{9: {"hive[bot]", tc.author}}, + timeline: map[int][]map[string]any{9: { + sentinelTimelineLabel("labeled", "hive[bot]", "Bot", "2026-10-22T01:00:00Z"), + sentinelTimelineForcePush("hB", "2026-10-22T06:25:00Z"), + sentinelTimelineLabel("unlabeled", "hive[bot]", "Bot", "2026-10-22T18:19:00Z"), + }}, + } + srv := newSentinelServer(t, f) + defer srv.Close() + c := newTestClient(t, srv, "o", []string{"o/r"}) + c.SetAppBotLogin("hive[bot]") + res, err := c.SweepSentinel(context.Background(), defaultSentinelOpts(nil)) + if err != nil || len(res.Flagged) != 1 || len(f.labels[9]) != 1 || len(f.comments[9]) != 3 || !strings.Contains(f.comments[9][2], SentinelMarker+" hB") { + t.Fatalf("new head must re-alert: res=%+v err=%v labels=%v comments=%v", res, err, f.labels[9], f.comments[9]) + } + }) + } +} + // The label removal counts only when it postdates a server-stamped push of // the current head and was made by a human who is not one of the hive's // accounts. A removal before the push, a removal by a hive account or From 06d8e795470144ba13c260abd4fb8fe5e685632a Mon Sep 17 00:00:00 2001 From: Andrew Anderson Date: Wed, 28 Oct 2026 21:30:56 -0400 Subject: [PATCH 2/2] test: stamp created_at on the Prow-rejection wire comments Signed-off-by: Andrew Anderson --- src/pkg/github/pr_decision_operator_test.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/pkg/github/pr_decision_operator_test.go b/src/pkg/github/pr_decision_operator_test.go index 51a007af5c..3f056b18b9 100644 --- a/src/pkg/github/pr_decision_operator_test.go +++ b/src/pkg/github/pr_decision_operator_test.go @@ -250,10 +250,11 @@ func TestRecordOperatorPullRequestApprovalWithoutOptionsStaysCommentsOnly(t *tes // decision without posting them again and says so on the event; a Prow // reply to someone else's comment, or no reply at all, changes nothing. func TestRecordOperatorPullRequestApprovalSkipsCommandsProwRejected(t *testing.T) { - ownLGTM := unparkWireComment{ID: 501, Body: renderPRApprovalCommandComment("/lgtm", "clubanderson", liveDecisionHead), User: wireUser{Login: "hive[bot]"}} - ownApprove := unparkWireComment{ID: 502, Body: renderPRApprovalCommandComment("/approve", "clubanderson", liveDecisionHead), User: wireUser{Login: "hive[bot]"}} + at := time.Date(2026, 10, 29, 0, 32, 0, 0, time.UTC).Format(time.RFC3339) + ownLGTM := unparkWireComment{ID: 501, Body: renderPRApprovalCommandComment("/lgtm", "clubanderson", liveDecisionHead), User: wireUser{Login: "hive[bot]"}, CreatedAt: at, UpdatedAt: at} + ownApprove := unparkWireComment{ID: 502, Body: renderPRApprovalCommandComment("/approve", "clubanderson", liveDecisionHead), User: wireUser{Login: "hive[bot]"}, CreatedAt: at, UpdatedAt: at} prowReply := func(id int64, text string) unparkWireComment { - return unparkWireComment{ID: 600 + id, Body: text + "\n\n
\n\nIn response to [this](https://github.com/org/repo/pull/1#issuecomment-" + strconv.FormatInt(id, 10) + "):\n\n>/lgtm\n
", User: wireUser{Login: "kubestellar-prow[bot]"}} + return unparkWireComment{ID: 600 + id, Body: text + "\n\n
\n\nIn response to [this](https://github.com/org/repo/pull/1#issuecomment-" + strconv.FormatInt(id, 10) + "):\n\n>/lgtm\n
", User: wireUser{Login: "kubestellar-prow[bot]"}, CreatedAt: at, UpdatedAt: at} } for _, tc := range []struct { name string @@ -263,7 +264,7 @@ func TestRecordOperatorPullRequestApprovalSkipsCommandsProwRejected(t *testing.T {"lgtm restricted", []unparkWireComment{ownLGTM, prowReply(501, "@hive[bot]: changing LGTM is restricted to collaborators")}, PRApprovalCommandsSkippedProw}, {"approve not approved", []unparkWireComment{ownApprove, prowReply(502, "[APPROVALNOTIFIER] This PR is **NOT APPROVED**")}, PRApprovalCommandsSkippedProw}, {"prow answered someone else", []unparkWireComment{ownLGTM, prowReply(77, "@eve: changing LGTM is restricted to collaborators")}, ""}, - {"human quoting the phrase", []unparkWireComment{ownLGTM, {ID: 700, Body: "NOT APPROVED, see #issuecomment-501)", User: wireUser{Login: "eve"}}}, ""}, + {"human quoting the phrase", []unparkWireComment{ownLGTM, {ID: 700, Body: "NOT APPROVED, see #issuecomment-501)", User: wireUser{Login: "eve"}, CreatedAt: at, UpdatedAt: at}}, ""}, {"no prior commands", nil, ""}, } { t.Run(tc.name, func(t *testing.T) {