From fe67aa3503b8cf0fb6b3448206fb9661f543c8cd Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:27:28 +0000 Subject: [PATCH 01/69] =?UTF-8?q?=F0=9F=90=9B=20dco:=20waive=20the=20misma?= =?UTF-8?q?tched=20sign-off=20on=20the=20squash=20of=20#17464=20(76b20ebe)?= =?UTF-8?q?=20(#17561)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .github/workflows/dco-post-merge.yml | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/dco-post-merge.yml b/.github/workflows/dco-post-merge.yml index 8f61fb8bf0..33c45342e7 100644 --- a/.github/workflows/dco-post-merge.yml +++ b/.github/workflows/dco-post-merge.yml @@ -324,6 +324,26 @@ env: # 3fedd0f3cbf5703a306157411a7136ecff738f5c — same shape, person and # disposition as 003144299b above (#15542). Reversible: remove the entry. + # 76b20ebe56639360ff27e15ed3751afc96c04785 — the squash of #17464, on v6, + # with the mismatched-signoff shape created by the squash: the branch + # commits were authored AND signed off as Danathar + # , an Apple iCloud "Hide My Email" relay + # address, so the PR was internally consistent; GitHub's squash then wrote + # the PR author's profile-primary identity, Danathar + # , over it while keeping that sign-off. Same class + # as 7e01fee4a2c1a37f4a4072bf2d17e76e27113d01 and + # 4b9261183378a1a02a921cd0cc9df31e6f37993b: one maintainer, two addresses, + # nothing about the certification in doubt. The checker should not infer the + # link: a gmail or relay address carries no structural proof that it belongs + # to the authoring account (same reasoning as 7e01fee), so this is a + # per-commit waiver and not a DCO_ALLOWLIST_EMAILS entry. Protected v6 + # history cannot be re-signed in place and no sign-off is rewritten on + # another person's behalf. Reported by the monitor in #17558. Accepted by + # maintainer disposition in #17558: the maintainer merging the PR that adds + # this entry IS that disposition. Reversible: remove the entry. To stop the + # squash producing this shape, the contributor can set the relay address as + # their GitHub profile-primary email, or sign off with the primary address. + # KNOWN FAILING COMMITS THAT ARE DELIBERATELY *NOT* WAIVED # # Deep history carries further genuine mismatches — 8b536911 and, on v5 @@ -335,7 +355,7 @@ env: # regression. They are intentionally left unwaived: pre-approving them would # grow this list for commits that are not actually being reported, which is # the exact failure mode #6770 was filed about. - DCO_WAIVED_COMMITS: 'b798382a4d98ada28b0cb813644a595db0c58b08 7e01fee4a2c1a37f4a4072bf2d17e76e27113d01 d8f376e8e95f7b0c7d48d2b05b3a2a07ac9ee69b 4b9261183378a1a02a921cd0cc9df31e6f37993b 01bd2469e7a4022fff3fc04c42226c4d90c2f410 e29343efbb6e0721ca665ed8bd587d08997325e2 a8104b0cbeee1c4ac41034ac3f9951e6b5ac1200 692d068ffa198895ab91bd7ad663971f2b8ad358 b893b01c90e6ffff951523d20b19e9dfbfa80184 a0de3f920ded7e0cfc287bb5009d542e5a14f014 c6c78c3a26c33c6d1530996df20ead0a6b699dda a9200f3d278fcdbf6291f37f921845113814686e fb153585e6dab7b6f6808cb328e706d691f9be79 00070300002c88fda6850278edaea2498e8ca941 511027d8174be02b1dd77c25e9f8d5265f7fb7d4 687c3cb006d7559135f5f2fb0db13476d1af2a43 003144299b952e53290088e7637ac12f6d5d20e9 8eb7267d3302bb3f68e718f4caf57826efb88ae3 3fedd0f3cbf5703a306157411a7136ecff738f5c' + DCO_WAIVED_COMMITS: 'b798382a4d98ada28b0cb813644a595db0c58b08 7e01fee4a2c1a37f4a4072bf2d17e76e27113d01 d8f376e8e95f7b0c7d48d2b05b3a2a07ac9ee69b 4b9261183378a1a02a921cd0cc9df31e6f37993b 01bd2469e7a4022fff3fc04c42226c4d90c2f410 e29343efbb6e0721ca665ed8bd587d08997325e2 a8104b0cbeee1c4ac41034ac3f9951e6b5ac1200 692d068ffa198895ab91bd7ad663971f2b8ad358 b893b01c90e6ffff951523d20b19e9dfbfa80184 a0de3f920ded7e0cfc287bb5009d542e5a14f014 c6c78c3a26c33c6d1530996df20ead0a6b699dda a9200f3d278fcdbf6291f37f921845113814686e fb153585e6dab7b6f6808cb328e706d691f9be79 00070300002c88fda6850278edaea2498e8ca941 511027d8174be02b1dd77c25e9f8d5265f7fb7d4 687c3cb006d7559135f5f2fb0db13476d1af2a43 003144299b952e53290088e7637ac12f6d5d20e9 8eb7267d3302bb3f68e718f4caf57826efb88ae3 3fedd0f3cbf5703a306157411a7136ecff738f5c 76b20ebe56639360ff27e15ed3751afc96c04785' # Tide/tagged-release failures discussed in #6276 came from human squash # commits and release metadata, not bot-authored commits. Skip bots here so # release automation is not paged for bracketed bot-address edge cases that From 7a4c0bea61d4b6f76d6fc79a35fafd4103c7701d Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:52:24 +0000 Subject: [PATCH 02/69] =?UTF-8?q?=F0=9F=90=9B=20dashboard:=20release=20hol?= =?UTF-8?q?d=20on=20an=20issue-via-PR=20row=20targets=20the=20covering=20P?= =?UTF-8?q?R=20(#17564)=20(#17567)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> --- ...-17564-release-hold-targets-covering-pr.md | 1 + src/pkg/dashboard/api_repo_hold.go | 35 +++++++++++++- src/pkg/dashboard/api_repo_hold_test.go | 28 +++++++++++ .../stage_tracker_row_actions_test.go | 46 +++++++++++++++++++ .../static-src/js/tracker-actions.js | 13 ++++++ src/pkg/dashboard/static/index.html | 13 ++++++ 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-17564-release-hold-targets-covering-pr.md diff --git a/changelog.d/fixed-17564-release-hold-targets-covering-pr.md b/changelog.d/fixed-17564-release-hold-targets-covering-pr.md new file mode 100644 index 0000000000..13414764fc --- /dev/null +++ b/changelog.d/fixed-17564-release-hold-targets-covering-pr.md @@ -0,0 +1 @@ +- Activity monitor: **Release hold** and **Confirm safe** on an issue row drawn through its covering PR now act on that PR, which carries the hold or sentinel, instead of silently no-oping on the issue; a release that finds no hold on an issue whose covering PR is held now says so and names the PR. diff --git a/src/pkg/dashboard/api_repo_hold.go b/src/pkg/dashboard/api_repo_hold.go index fca6d7d34a..ddf59711a2 100644 --- a/src/pkg/dashboard/api_repo_hold.go +++ b/src/pkg/dashboard/api_repo_hold.go @@ -5,6 +5,7 @@ import ( "encoding/json" "fmt" "net/http" + "slices" "strconv" "strings" "time" @@ -46,6 +47,30 @@ func repoHoldResult(repoFull string, number int, itemType string, held bool, lab Next: "The hive picks it up on its next pass."} } +// repoHoldCoveringPR is the open covering PR that carries the hold an +// issue row shows (the row draws it, so its gate pill reads the PR's hold), +// or 0. A release on the issue removes nothing there +// (hivecommons/hive#17564). +func repoHoldCoveringPR(it StageTrackerItem) int { + for _, lp := range it.LinkedPRs { + if lp.State == "closed" || (lp.DrawnUnder != 0 && lp.DrawnUnder != it.Number) { + continue + } + if lp.Hold != nil || slices.Contains(lp.Modifiers, modHold) { + return lp.Number + } + } + return 0 +} + +// repoHoldElsewhereResult answers a release that removed nothing from an +// issue whose covering PR carries the hold: no effect, naming the PR. +func repoHoldElsewhereResult(repoFull string, number, pr int) *RowActionResult { + return &RowActionResult{Action: rowActionNoEffect, Target: rowActionTarget(repoFull, rowActionTargetIssue, number), + Outcome: "Nothing to release on #" + strconv.Itoa(number) + " — the hold is on #" + strconv.Itoa(pr) + ".", + Next: "Release the hold on PR #" + strconv.Itoa(pr) + "."} +} + type repoHoldPermissionCacheEntry struct { allowed bool at time.Time @@ -680,6 +705,14 @@ func (s *Server) handleRepoItemHold(w http.ResponseWriter, r *http.Request) { itemType = "issue" } minStatusSeq := s.applyRepoHoldToStatus(repoFull, number, itemType, body.Held, canonical, removed) + result := repoHoldResult(repoFull, number, itemType, body.Held, canonical, removed) + if !body.Held && len(removed) == 0 && itemType == rowActionTargetIssue { + if it, ok := s.stageTrackerItemFor(repoFull, number); ok { + if pr := repoHoldCoveringPR(it); pr > 0 { + result = repoHoldElsewhereResult(repoFull, number, pr) + } + } + } jsonResponse(w, repoHoldResponse{ OK: true, Repo: repoFull, @@ -688,6 +721,6 @@ func (s *Server) handleRepoItemHold(w http.ResponseWriter, r *http.Request) { HoldLabel: canonical, Removed: removed, MinStatusSeq: minStatusSeq, - Result: repoHoldResult(repoFull, number, itemType, body.Held, canonical, removed), + Result: result, }) } diff --git a/src/pkg/dashboard/api_repo_hold_test.go b/src/pkg/dashboard/api_repo_hold_test.go index f76240c2df..550a45a5bd 100644 --- a/src/pkg/dashboard/api_repo_hold_test.go +++ b/src/pkg/dashboard/api_repo_hold_test.go @@ -290,3 +290,31 @@ func TestRepoHoldPermissionEndpointUsesCachedGitHubPermission(t *testing.T) { t.Fatalf("permission response: code=%d body=%s", w.Code, w.Body.String()) } } + +// TestRepoHoldReleaseOnIssueNamesCoveringPRHold: a release on an issue that +// removed nothing, while the covering PR the row draws carries the hold, is +// a no-effect answer naming the PR — not a silent "no change" +// (hivecommons/hive#17564). +func TestRepoHoldReleaseOnIssueNamesCoveringPRHold(t *testing.T) { + issue := StageTrackerItem{Repo: "o/r", Kind: "issue", Number: 17558, LinkedPRs: []StageTrackerLinkedPR{ + {Number: 17500, State: "closed", Modifiers: []string{modHold}}, + {Number: 17559, DrawnUnder: 17000, Modifiers: []string{modHold}}, + {Number: 17561, Modifiers: []string{modHold}}, + }} + if got := repoHoldCoveringPR(issue); got != 17561 { + t.Fatalf("repoHoldCoveringPR = %d, want 17561 (open, drawn here, held)", got) + } + if got := repoHoldCoveringPR(StageTrackerItem{Number: 1, LinkedPRs: []StageTrackerLinkedPR{{Number: 2}}}); got != 0 { + t.Fatalf("repoHoldCoveringPR on an unheld PR = %d, want 0", got) + } + if got := repoHoldCoveringPR(StageTrackerItem{Number: 1, LinkedPRs: []StageTrackerLinkedPR{{Number: 3, Hold: &StageTrackerHold{}}}}); got != 3 { + t.Fatalf("repoHoldCoveringPR with a hold record = %d, want 3", got) + } + res := repoHoldElsewhereResult("o/r", 17558, 17561) + if res.Action != rowActionNoEffect || res.Target.Number != 17558 || res.Target.Kind != rowActionTargetIssue { + t.Fatalf("result = %+v, want no-effect on the issue", res) + } + if want := "Nothing to release on #17558 — the hold is on #17561."; res.Outcome != want { + t.Fatalf("outcome = %q, want %q", res.Outcome, want) + } +} diff --git a/src/pkg/dashboard/stage_tracker_row_actions_test.go b/src/pkg/dashboard/stage_tracker_row_actions_test.go index 73b89760f2..22741f715a 100644 --- a/src/pkg/dashboard/stage_tracker_row_actions_test.go +++ b/src/pkg/dashboard/stage_tracker_row_actions_test.go @@ -2076,3 +2076,49 @@ _stageTracker = { items: [t1, plain, t2, pr] }; })().catch(e => { console.error(e); process.exit(1); }); `) } + +// TestStageTrackerReleaseHoldTargetsCoveringPR: an issue row drawn through +// its one covering PR shows the PR's hold (and sentinel) on its gate pill, +// so Release hold and Confirm safe post to the PR, not to the issue +// (hivecommons/hive#17564 — the release ran on the issue, removed nothing +// and the PR stayed held). An issue that carries the hold itself, or one +// with several covering PRs, keeps acting on the issue. +func TestStageTrackerReleaseHoldTargetsCoveringPR(t *testing.T) { + html := indexHTML(t) + runStageTrackerRowActionsScript(t, stageTrackerRowActionsPreamble(t, html)+` +const pr = { number: 17561, url: 'https://github.com/o/r/pull/17561', stage: 90, modifiers: ['hold'], hold: { by: 'hive' }, sentinel_alert: true }; +const issue = { repo: 'o/r', kind: 'issue', number: 17558, url: 'u17558', stage: 50, modifiers: [], linked_prs: [pr] }; +const ownHold = Object.assign({}, issue, { number: 17600, modifiers: ['hold'] }); +const twoPRs = Object.assign({}, issue, { number: 17601, linked_prs: [pr, { number: 17562, stage: 40, modifiers: ['hold'] }] }); +const calls = []; +global.fetch = async (url, init) => { calls.push({ url, body: JSON.parse(init.body) }); return { ok: true, status: 200, json: async () => ({ ok: true, result: { action: 'released', target: { repo: 'o/r', kind: 'pr', number: 17561 }, outcome: 'Hold released.' } }) }; }; +global.showToast = () => null; global.dismissToast = () => {}; +function stageTrackerProgressToast() { return { update() {}, done() {} }; } +function stageTrackerAfterActions() {} +function stageTrackerNoteOwnerEvent() {} +async function stageTrackerActionPayload() { return {}; } +_stageTracker = { items: [issue, ownHold, twoPRs] }; +(async () => { + await runRowAction('release', issue); + assert.deepStrictEqual(calls.map(c => c.url), ['/api/repos/o/r/items/17561/hold'], 'Release hold on the issue row posts to the covering PR'); + assert.deepStrictEqual(calls[0].body, { held: false, type: 'pr' }); + + calls.length = 0; + await runRowAction('gate:confirm-sentinel', issue); + assert.deepStrictEqual(calls.map(c => c.url), ['/api/repos/o/r/items/17561/sentinel-confirm'], 'Confirm safe on the issue row posts to the covering PR'); + assert.strictEqual(calls[0].body.type, 'pr'); + + calls.length = 0; + await runRowAction('release', [issue, Object.assign({ repo: 'o/r', kind: 'pr' }, pr)]); + assert.deepStrictEqual(calls.map(c => c.url), ['/api/repos/o/r/items/17561/hold'], 'the PR is released once when its row is selected too'); + + calls.length = 0; + await runRowAction('release', ownHold); + assert.deepStrictEqual(calls.map(c => c.url), ['/api/repos/o/r/items/17600/hold'], 'an issue that is held itself releases its own hold'); + + calls.length = 0; + await runRowAction('release', twoPRs); + assert.deepStrictEqual(calls.map(c => c.url), ['/api/repos/o/r/items/17601/hold'], 'several covering PRs: no single PR to retarget to'); +})().catch(e => { console.error(e); process.exit(1); }); +`) +} diff --git a/src/pkg/dashboard/static-src/js/tracker-actions.js b/src/pkg/dashboard/static-src/js/tracker-actions.js index 691b54825c..3525a85868 100644 --- a/src/pkg/dashboard/static-src/js/tracker-actions.js +++ b/src/pkg/dashboard/static-src/js/tracker-actions.js @@ -2703,6 +2703,19 @@ // decision park, so it has no decision target. items = items.filter(it => { const d = stageTrackerDeferralOf(it); return !!(d && d.close_ok); }); if (!items.length) { stageTrackerNothingToActOn(id, rows); return { toasts: [], pending: [] }; } + } else if (id === 'release' || id === 'gate:confirm-sentinel') { + // An issue row drawn through its one covering PR shows the PR's hold + // or sentinel on its gate pill (stageTrackerHumanGateReasons reads + // the PR's): Release hold / Confirm safe act on that PR, as Approve + // does, unless the issue carries the hold or sentinel itself + // (hivecommons/hive#17564 — the release ran on the issue and no-oped). + const carries = x => !!x && (id === 'release' ? (!!x.hold || (Array.isArray(x.modifiers) && x.modifiers.indexOf('hold') >= 0)) : !!x.sentinel_alert); + const seen = {}; + items = items.map(it => { + if (!it || it.kind === 'pr' || carries(it)) return it; + const here = (Array.isArray(it.linked_prs) ? it.linked_prs : []).filter(lp => lp && (!Number(lp.drawn_under) || Number(lp.drawn_under) === Number(it.number)) && stageTrackerLinkedPROpen(lp, it)); + return here.length === 1 && carries(here[0]) ? stageTrackerLinkedPRItem(it, here[0]) : it; + }).filter(t => t && !seen[stageTrackerItemKey(t)] && (seen[stageTrackerItemKey(t)] = true)); } else if (id.indexOf('decide:') === 0) { // A row decides its parked PR when it has one (the issue's stage is // only mirrored from it); dedupe when the PR row is selected too. diff --git a/src/pkg/dashboard/static/index.html b/src/pkg/dashboard/static/index.html index 83725e0885..750e7ba5b6 100644 --- a/src/pkg/dashboard/static/index.html +++ b/src/pkg/dashboard/static/index.html @@ -26119,6 +26119,19 @@

All labels

// decision park, so it has no decision target. items = items.filter(it => { const d = stageTrackerDeferralOf(it); return !!(d && d.close_ok); }); if (!items.length) { stageTrackerNothingToActOn(id, rows); return { toasts: [], pending: [] }; } + } else if (id === 'release' || id === 'gate:confirm-sentinel') { + // An issue row drawn through its one covering PR shows the PR's hold + // or sentinel on its gate pill (stageTrackerHumanGateReasons reads + // the PR's): Release hold / Confirm safe act on that PR, as Approve + // does, unless the issue carries the hold or sentinel itself + // (hivecommons/hive#17564 — the release ran on the issue and no-oped). + const carries = x => !!x && (id === 'release' ? (!!x.hold || (Array.isArray(x.modifiers) && x.modifiers.indexOf('hold') >= 0)) : !!x.sentinel_alert); + const seen = {}; + items = items.map(it => { + if (!it || it.kind === 'pr' || carries(it)) return it; + const here = (Array.isArray(it.linked_prs) ? it.linked_prs : []).filter(lp => lp && (!Number(lp.drawn_under) || Number(lp.drawn_under) === Number(it.number)) && stageTrackerLinkedPROpen(lp, it)); + return here.length === 1 && carries(here[0]) ? stageTrackerLinkedPRItem(it, here[0]) : it; + }).filter(t => t && !seen[stageTrackerItemKey(t)] && (seen[stageTrackerItemKey(t)] = true)); } else if (id.indexOf('decide:') === 0) { // A row decides its parked PR when it has one (the issue's stage is // only mirrored from it); dedupe when the PR row is selected too. From b372e9f116ada761ece8d0b4877c680c8ef7293d Mon Sep 17 00:00:00 2001 From: hive-release-bot Date: Tue, 10 Nov 2026 18:21:22 +0000 Subject: [PATCH 03/69] =?UTF-8?q?=F0=9F=94=96=20release:=20v5.211.19?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated release commit. Compiles changelog.d/ fragments and moves the CHANGELOG.md Unreleased section into a dated v5.211.19 entry. See src/docs/releases.md. Signed-off-by: hive-release-bot --- CHANGELOG.md | 6 ++++++ changelog.d/fixed-17564-release-hold-targets-covering-pr.md | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 changelog.d/fixed-17564-release-hold-targets-covering-pr.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 0c26ac384a..53351ee8bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ Hive did not historically maintain a complete changelog. This file starts a prag ## Unreleased +## 2026-11-10 (v5.211.19) + +### Fixed + +- Activity monitor: **Release hold** and **Confirm safe** on an issue row drawn through its covering PR now act on that PR, which carries the hold or sentinel, instead of silently no-oping on the issue; a release that finds no hold on an issue whose covering PR is held now says so and names the PR. + ## 2026-11-10 (v5.211.18) ### Fixed diff --git a/changelog.d/fixed-17564-release-hold-targets-covering-pr.md b/changelog.d/fixed-17564-release-hold-targets-covering-pr.md deleted file mode 100644 index 13414764fc..0000000000 --- a/changelog.d/fixed-17564-release-hold-targets-covering-pr.md +++ /dev/null @@ -1 +0,0 @@ -- Activity monitor: **Release hold** and **Confirm safe** on an issue row drawn through its covering PR now act on that PR, which carries the hold or sentinel, instead of silently no-oping on the issue; a release that finds no hold on an issue whose covering PR is held now says so and names the PR. From ae32a64e42983ed63b24956d7a06e266ff434f5a Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 18:51:39 +0000 Subject: [PATCH 04/69] =?UTF-8?q?=F0=9F=8C=B1=20mutation:=20verdict=20phas?= =?UTF-8?q?e=20and=20misrouted/uncovered=20detection=20for=20the=20PR=20mu?= =?UTF-8?q?tation=20report=20(#17569)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🌱 mutation: verdict phase and misrouted/uncovered detection for the PR mutation report The Phase 2 decision on #17349 asks the mutation job to (1) tell a run that produced no mutants because the diff was not matched from one whose added lines simply contain nothing gremlins can mutate, (2) fail on survivors and (3) warn on uncovered mutants with a label override. All of that logic lives in the script, which this change adds; the workflow step that calls the new verdict phase is left for a human to land (see the issue). Run 42842443653 (PR #17557) is the reference case for (1): gremlins v0.6.0 has no mutator for unary ! or for return values, so 'if !looksLikeUUID(id) { return "" }' yields zero mutants and the 108 SKIPPED ones all sit on unchanged lines. Counting added lines alone would have failed that PR wrongly; a SKIPPED mutant inside an added range is the actual signature of a matching fault. Refs #17349 Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🌱 mutation: honour gremlins' hunk approximation and fail closed on a missing report Review fixes for #17569: - misrouted was judged against the exact -U0 added ranges, but gremlins v0.6.0 honours only start=+pos+leading-context, end=start+added-1 per default-context hunk, so a hunk with non-contiguous added lines made the script fail legitimate PRs. Derive that range (gremlins.tsv) from the same default-context diff; SKIPPED inside it is misrouted, SKIPPED on an added line outside it is a non-blocking hunk-approximation note. - A gremlins non-zero exit or missing JSON produced verdict=pass with a false "nothing to mutate" explanation. Record each failed package in errors.tsv, write verdict=error, report it in the comment, and make the verdict phase exit 1 on error and on a missing verdict file (#17349 item 1). - has_label: make arr local. - test-mutation-report.sh: stub gains GREMLINS_EXIT/GREMLINS_NO_OUTPUT, new split-hunk and failing-stub cases, missing-verdict expectation flipped. Hive-Fix-Attempt: 1/6 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🌱 mutation: re-pin TRUSTED_SCRIPTS_TREE to the mutation-report.sh tree The second commit edited src/scripts/mutation-report.sh after the first re-pin, so runtime-tests' integration-governance contract failed on the stale literal. Pin to git rev-parse HEAD:src/scripts. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/scripts/integration-governance.cjs | 2 +- changelog.d/changed-17349-mutation-verdict.md | 1 + src/scripts/mutation-report.sh | 225 +++++++++++++++--- src/scripts/test-mutation-report.sh | 190 +++++++++++++++ 4 files changed, 389 insertions(+), 29 deletions(-) create mode 100644 changelog.d/changed-17349-mutation-verdict.md create mode 100755 src/scripts/test-mutation-report.sh diff --git a/.github/scripts/integration-governance.cjs b/.github/scripts/integration-governance.cjs index 55cae21afd..e44dee70e3 100644 --- a/.github/scripts/integration-governance.cjs +++ b/.github/scripts/integration-governance.cjs @@ -9,7 +9,7 @@ const MAX_COMMITS = 1000; const MAX_AUTHOR_BATCH = 50; // This literal is inside the enrolled .github closure. A caller-supplied // preparedBy.sourceSHA must never choose a new executable verifier tree. -const TRUSTED_SCRIPTS_TREE = '653f37e12ab9437a39057f4baea8dd96657e63f5'; +const TRUSTED_SCRIPTS_TREE = '94db1adcdc2e3c367b8a04f2d3643ca18ee973c4'; const SOURCE = 'https://github.com/kubernetes-sigs/kubebuilder-release-tools/tree/012269a88fa4c034a0acf1ba84c26b195c0dbab4'; const sha = value => crypto.createHash('sha256').update(value).digest('hex'); const git = (args, cwd = process.cwd()) => diff --git a/changelog.d/changed-17349-mutation-verdict.md b/changelog.d/changed-17349-mutation-verdict.md new file mode 100644 index 0000000000..17da3d205a --- /dev/null +++ b/changelog.d/changed-17349-mutation-verdict.md @@ -0,0 +1 @@ +- CI mutation report (`src/scripts/mutation-report.sh`): the `` PR comment now also lists NOT COVERED mutants in changed files and tells a zero-mutant run apart from a broken one — a SKIPPED mutant on an added line gremlins honours (it only matches the first `lines added` lines of each default-context hunk; the rest are noted, not flagged) is flagged as a diff-matching fault, a gremlins failure or missing report is an `error` verdict rather than a silent pass, while added lines with nothing gremlins can mutate (a unary `!`, a bare `return`) are reported as such instead of "no surviving mutants". A new `verdict` phase exits non-zero on `error`/`lived`/`misrouted` or a missing verdict file and warns on `uncovered` unless the PR carries `mutation/acknowledged`, so a workflow can block on it (#17349, Phase 2). diff --git a/src/scripts/mutation-report.sh b/src/scripts/mutation-report.sh index 5187c11e66..bfc360d55e 100755 --- a/src/scripts/mutation-report.sh +++ b/src/scripts/mutation-report.sh @@ -1,20 +1,89 @@ #!/usr/bin/env bash -# Advisory mutation report for the Go packages a PR touches (#17349, Phase 1). +# Mutation report for the Go packages a PR touches (#17349). # Runs gremlins on the lines each changed package's diff adds (#17463), then -# upserts ONE PR comment listing surviving (LIVED) -# mutants in changed files. Never fails. +# upserts ONE PR comment listing surviving (LIVED) and +# uncovered (NOT_COVERED) mutants in changed files. # -# Two phases so the token never shares an environment with PR-controlled code: -# mutation-report.sh run runs gremlins (no GH_TOKEN) and writes -# $out_dir/comment.md -# mutation-report.sh post reads comment.md and upserts the PR comment -# (needs GH_TOKEN, PR_NUMBER, GITHUB_REPOSITORY) +# Three phases so the token never shares an environment with PR-controlled code: +# mutation-report.sh run runs gremlins (no GH_TOKEN) and writes +# $out_dir/comment.md and $out_dir/verdict. +# Always exits 0. +# mutation-report.sh post reads comment.md and upserts the PR comment +# (needs GH_TOKEN, PR_NUMBER, GITHUB_REPOSITORY) +# mutation-report.sh verdict exits 1 when $out_dir/verdict is `error`, +# `lived` or `misrouted`, or when the file is +# missing (the run phase did not finish); +# `uncovered` only warns (silenced by a +# `mutation/acknowledged` label in PR_LABELS, +# comma-separated). Phase 2 of #17349: a workflow +# that wants to block runs this phase as its own +# step. +# +# Verdicts, in precedence order: +# error gremlins exited non-zero or wrote no report for a package, so +# there is nothing to judge. Never silently `pass` (#17349, item 1). +# misrouted a mutant on a line the PR added was SKIPPED, so gremlins did not +# recognise the diff for that file. Mutants on unchanged lines are +# always SKIPPED under --diff, so that count alone proves nothing: +# only a SKIPPED mutant inside a range gremlins honours does. A +# diff with no mutable operator at all (a unary `!`, a bare +# `return`) produces zero mutants legitimately and is `pass`. +# gremlins v0.6.0 approximates each default-context hunk as +# start = +position + leading context, end = start + lines added +# - 1 (internal/diff/diff.go), so a hunk whose added lines are not +# contiguous (edits <= 6 lines apart share one hunk) only honours +# the first `lines added` lines. SKIPPED mutants on added lines +# outside that approximation are gremlins' own doing and are +# reported as a non-blocking note, not as `misrouted`. +# lived a mutant in a changed file survived the tests. +# uncovered a mutant in a changed file is not reached by any test. +# pass everything else, including "nothing to mutate". set -uo pipefail phase="${1:-run}" marker='' out_dir="${MUTATION_OUT_DIR:-mutation-out}" body="$out_dir/comment.md" +verdict_file="$out_dir/verdict" + +has_label() { + local want="$1" labels="${PR_LABELS:-}" l arr + IFS=',' read -r -a arr <<< "$labels" + for l in "${arr[@]}"; do + [ "$(printf '%s' "$l" | sed 's/^ *//; s/ *$//')" = "$want" ] && return 0 + done + return 1 +} + +verdict_phase() { + local v + if [ ! -f "$verdict_file" ]; then + echo "::error::mutation: no verdict at $verdict_file; the run phase did not finish (see its log)" + return 1 + fi + v=$(cat "$verdict_file") + case "$v" in + error) + echo "::error::mutation: gremlins failed or wrote no report for a changed package, so no verdict could be derived (see the run log and the comment)" + return 1 ;; + misrouted) + echo "::error::mutation: a mutant on a line this PR added was SKIPPED; gremlins did not match the diff for that file (see the comment)" + return 1 ;; + lived) + echo "::error::mutation: surviving mutant(s) in changed files; the code ran under tests but no test fails when it changes (see the comment)" + return 1 ;; + uncovered) + if has_label 'mutation/acknowledged'; then + echo "mutation: uncovered mutant(s) in changed files acknowledged via the mutation/acknowledged label." + else + echo "::warning::mutation: mutant(s) in changed files are not reached by any test (see the comment); a maintainer may apply mutation/acknowledged" + fi + return 0 ;; + *) + echo "mutation: $v" + return 0 ;; + esac +} post_comment() { local pr_number="${PR_NUMBER:-}" repo="${GITHUB_REPOSITORY:-}" @@ -42,8 +111,9 @@ post_comment() { case "$phase" in post) post_comment; exit 0 ;; + verdict) verdict_phase; exit $? ;; run) ;; - *) echo "usage: $0 [run|post]" >&2; exit 0 ;; + *) echo "usage: $0 [run|post|verdict]" >&2; exit 0 ;; esac if [ -n "${GH_TOKEN:-}${GITHUB_TOKEN:-}" ]; then @@ -68,10 +138,37 @@ changed="${kept%$'\n'}" if [ -z "$changed" ]; then echo "No changed non-test Go files; skipping mutation run." + echo pass > "$verdict_file" exit 0 fi printf '%s\n' "$changed" > "$out_dir/changed.txt" + +# Added-line ranges per changed file (filestartend), from the same +# merge-base diff gremlins reads: added.tsv holds the exact -U0 added lines; +# gremlins.tsv holds the range gremlins v0.6.0 actually honours per +# default-context hunk (+position + leading context, for `lines added` lines). +# A SKIPPED mutant inside a gremlins.tsv range means gremlins did not recognise +# the file as changed; one inside added.tsv only is its hunk approximation. +added="$out_dir/added.tsv" +honoured="$out_dir/gremlins.tsv" +: > "$added" +: > "$honoured" +while IFS= read -r f; do + [ -n "$f" ] || continue + git diff -U0 "origin/${base_ref}...HEAD" -- "$f" \ + | awk -v f="$f" '/^@@ / { split($3, p, ","); s = substr(p[1], 2) + 0; n = (p[2] == "" ? 1 : p[2] + 0); if (n > 0) printf "%s\t%d\t%d\n", f, s, s + n - 1 }' >> "$added" + # No -U: gremlins runs `git diff --merge-base` with the default context. + git diff "origin/${base_ref}...HEAD" -- "$f" \ + | awk -v f="$f" ' + function flush() { if (hunk && add > 0) printf "%s\t%d\t%d\n", f, start + lead, start + lead + add - 1 } + /^@@ / { flush(); split($3, p, ","); start = substr(p[1], 2) + 0; lead = 0; add = 0; seen = 0; hunk = 1; next } + !hunk { next } + /^ / { if (!seen) lead++; next } + /^\+/ { seen = 1; add++; next } + /^-/ { seen = 1; next } + END { flush() }' >> "$honoured" +done <<< "$changed" pkgs=$(sed 's|^src/||; s|/[^/]*$||' "$out_dir/changed.txt" | sort -u) # gremlins mutates the whole subtree under a package, so drop packages that @@ -94,55 +191,127 @@ pkgs="${roots%$'\n'}" # package-relative paths; otherwise every mutant would be skipped, or (with no # --diff) the whole package is mutated and the job times out (#17463). Coverage # chdirs to the module root, so the output path must be absolute. +errors="$out_dir/errors.tsv" +: > "$errors" i=0 while IFS= read -r pkg; do [ -n "$pkg" ] || continue i=$((i + 1)) printf '%s\n' "$pkg" > "$out_dir/pkg-$i.dir" echo "::group::gremlins unleash ./$pkg --diff origin/${base_ref}" + rc=0 (cd "src/$pkg" && GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=diff.relative GIT_CONFIG_VALUE_0=true \ gremlins unleash --timeout-coefficient "$coefficient" --diff "origin/${base_ref}" \ - --output "$out_abs/pkg-$i.json") || echo "gremlins exited non-zero for $pkg (advisory)" + --output "$out_abs/pkg-$i.json") || rc=$? echo "::endgroup::" + # gremlins writes no report when it errors or is cancelled, so either sign + # means this package was not judged: record it rather than pass by default. + if [ "$rc" -ne 0 ]; then + echo "::error::gremlins exited $rc for $pkg" + printf '%s\texited %d\n' "$pkg" "$rc" >> "$errors" + elif [ ! -s "$out_abs/pkg-$i.json" ]; then + echo "::error::gremlins wrote no report for $pkg" + printf '%s\twrote no report\n' "$pkg" >> "$errors" + fi done <<< "$pkgs" # gremlins reports file_name relative to the package dir it was run on, so -# re-anchor each survivor to a repo-relative path before matching changed.txt. -survivors="$out_dir/survivors.tsv" -: > "$survivors" +# re-anchor every mutant to a repo-relative path before matching changed.txt. +# Only mutants in files the PR changed are kept: filelinetypestatus. +mutants="$out_dir/mutants-changed.tsv" +: > "$mutants" for j in "$out_dir"/pkg-*.json; do [ -f "$j" ] || continue pkg=$(cat "${j%.json}.dir" 2>/dev/null || true) jq -r --arg prefix "src/${pkg:+$pkg/}" \ - '.files[]? | .file_name as $f | .mutations[]? | select(.status=="LIVED") - | [($prefix + ($f | ltrimstr("./"))), .line, .type] | @tsv' "$j" >> "$survivors" 2>/dev/null || true + '.files[]? | .file_name as $f | .mutations[]? + | [($prefix + ($f | ltrimstr("./"))), .line, .type, .status] | @tsv' "$j" 2>/dev/null \ + | while IFS=$'\t' read -r f line type status; do + [ -n "$f" ] || continue + grep -qxF "$f" "$out_dir/changed.txt" && printf '%s\t%s\t%s\t%s\n' "$f" "$line" "$type" "$status" + done >> "$mutants" done -# Keep only survivors in files the PR changed. filtered="$out_dir/survivors-changed.tsv" -: > "$filtered" -while IFS=$'\t' read -r f line type; do - [ -n "$f" ] || continue - if grep -qxF "$f" "$out_dir/changed.txt"; then - printf '%s\t%s\t%s\n' "$f" "$line" "$type" >> "$filtered" - fi -done < "$survivors" +uncovered="$out_dir/uncovered-changed.tsv" +misrouted="$out_dir/misrouted-changed.tsv" +unhonoured="$out_dir/unhonoured-changed.tsv" +awk -F'\t' '$4=="LIVED" {print $1"\t"$2"\t"$3}' "$mutants" > "$filtered" +awk -F'\t' '$4=="NOT COVERED" {print $1"\t"$2"\t"$3}' "$mutants" > "$uncovered" +# in_ranges : SKIPPED mutants whose line falls in a range. +in_ranges() { + awk -F'\t' 'NR==FNR { if ($1 != "") { n[$1]++; s[$1,n[$1]]=$2; e[$1,n[$1]]=$3 } ; next } + $4=="SKIPPED" { for (k=1; k<=n[$1]; k++) if ($2+0 >= s[$1,k]+0 && $2+0 <= e[$1,k]+0) { print $1"\t"$2"\t"$3; break } }' "$1" "$2" +} +# SKIPPED inside a range gremlins honours: it saw the file but not its diff. +in_ranges "$honoured" "$mutants" > "$misrouted" +# SKIPPED on an added line gremlins' hunk approximation leaves out: advisory. +in_ranges "$added" "$mutants" | grep -vxF -f "$misrouted" > "$unhonoured" || true +mutated=$(awk -F'\t' '$4=="LIVED" || $4=="KILLED" || $4=="NOT COVERED" || $4=="TIMED OUT" {c++} END {print c+0}' "$mutants") +skipped=$(awk -F'\t' '$4=="SKIPPED" {c++} END {print c+0}' "$mutants") +added_lines=$(awk -F'\t' '{c += $3 - $2 + 1} END {print c+0}' "$added") + +if [ -s "$errors" ]; then verdict=error +elif [ -s "$misrouted" ]; then verdict=misrouted +elif [ -s "$filtered" ]; then verdict=lived +elif [ -s "$uncovered" ]; then verdict=uncovered +else verdict=pass +fi +echo "$verdict" > "$verdict_file" + +table() { sort -t$'\t' -k1,1 -k2,2n "$1" | head -n 100 | awk -F'\t' '{printf "| `%s` | %s | %s |\n", $1, $2, $3}'; } { echo "$marker" - echo "### Mutation testing (advisory)" + echo "### Mutation testing" echo + if [ -s "$errors" ]; then + echo "❌ **gremlins did not produce a report for $(wc -l < "$errors" | tr -d ' ') package(s)**, so no verdict can be derived from this run (see the job log):" + echo + awk -F'\t' '{printf "- `%s`: gremlins %s\n", $1, $2}' "$errors" + echo + fi + if [ -s "$misrouted" ]; then + echo "⚠️ **$(wc -l < "$misrouted" | tr -d ' ') mutant(s) on lines this PR added were SKIPPED**: gremlins did not recognise the diff for these files, so nothing below can be trusted. This is a tooling fault (diff path matching), not a test gap." + echo + echo "| File | Line | Mutation |" + echo "|---|---|---|" + table "$misrouted" + echo + fi if [ -s "$filtered" ]; then echo "gremlins found **$(wc -l < "$filtered" | tr -d ' ') surviving mutant(s)** in changed files: the code ran under tests, but changing it did not fail any test." echo echo "| File | Line | Mutation |" echo "|---|---|---|" - sort -t$'\t' -k1,1 -k2,2n "$filtered" | head -n 100 | awk -F'\t' '{printf "| `%s` | %s | %s |\n", $1, $2, $3}' - else - echo "No surviving mutants in changed files (or the run hit its time budget before reporting any)." + table "$filtered" + echo + fi + if [ -s "$uncovered" ]; then + echo "**$(wc -l < "$uncovered" | tr -d ' ') mutant(s) in changed files are not reached by any test** (NOT COVERED). A maintainer may apply the \`mutation/acknowledged\` label to accept this." + echo + echo "| File | Line | Mutation |" + echo "|---|---|---|" + table "$uncovered" + echo + fi + if [ -s "$unhonoured" ]; then + echo "ℹ️ $(wc -l < "$unhonoured" | tr -d ' ') mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours the first \`lines added\` lines of each default-context hunk, so non-contiguous edits in one hunk are partly missed. This does not affect the verdict." + echo + echo "| File | Line | Mutation |" + echo "|---|---|---|" + table "$unhonoured" + echo + fi + if [ -s "$errors" ]; then + : + elif [ "$mutated" -eq 0 ] && [ ! -s "$misrouted" ]; then + echo "No mutants in changed files: the $added_lines added line(s) contain no operator gremlins can mutate ($skipped mutant(s) on unchanged lines skipped as expected)." + elif [ ! -s "$filtered" ] && [ ! -s "$uncovered" ] && [ ! -s "$misrouted" ]; then + echo "All $mutated mutant(s) in changed files were killed." fi echo - echo "_Advisory only; this job never blocks the PR (#17349)._" + echo "_Verdict: \`$verdict\` (#17349)._" } > "$body" cat "$body" exit 0 diff --git a/src/scripts/test-mutation-report.sh b/src/scripts/test-mutation-report.sh new file mode 100755 index 0000000000..defff77325 --- /dev/null +++ b/src/scripts/test-mutation-report.sh @@ -0,0 +1,190 @@ +#!/usr/bin/env bash +# test-mutation-report.sh — exercises mutation-report.sh against a throwaway +# git repository and a stub `gremlins` that replays a canned JSON report, so +# the verdict logic (error / misrouted / lived / uncovered / pass) is pinned without +# compiling or mutating any Go. +set -u -o pipefail + +HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +SCRIPT="${SCRIPT:-${HERE}/mutation-report.sh}" +TMP_ROOT="${HERE}/../.test-tmp" +mkdir -p "$TMP_ROOT" +TMP="$(mktemp -d "$TMP_ROOT/mutation-report.XXXXXX")" +trap 'rm -rf "$TMP"' EXIT + +fail=0 +pass() { echo " ok: $*"; } +bad() { echo " FAIL: $*"; fail=1; } +out_grep() { grep "$@" <<<"$output"; } + +# Stub gremlins: copies $GREMLINS_FIXTURE to the --output path. GREMLINS_EXIT=N +# makes it exit N without writing a report (gremlins returns before report.Do +# on error); GREMLINS_NO_OUTPUT=1 exits 0 without writing one. +mkdir -p "$TMP/bin" +cat > "$TMP/bin/gremlins" <<'EOF' +#!/usr/bin/env bash +out="" +while [ $# -gt 0 ]; do + case "$1" in --output) out="$2"; shift ;; esac + shift +done +echo "stub gremlins ran in $(pwd)" +[ -n "${GREMLINS_EXIT:-}" ] && exit "$GREMLINS_EXIT" +[ -n "${GREMLINS_NO_OUTPUT:-}" ] && exit 0 +[ -n "$out" ] && cp "$GREMLINS_FIXTURE" "$out" +EOF +chmod +x "$TMP/bin/gremlins" +export PATH="$TMP/bin:$PATH" + +# Repo: base commit with src/pkg/x/x.go at 10 lines; HEAD adds lines 11-13. +repo="$TMP/repo" +mkdir -p "$repo/src/pkg/x" +cd "$repo" || exit 1 +git init -q +git config user.name 'Test' +git config user.email 'test@example.com' +for i in $(seq 1 10); do echo "// line $i" >> src/pkg/x/x.go; done +printf 'package x\n' > src/pkg/x/doc.go +git add . && git commit -q -m base +git update-ref refs/remotes/origin/main HEAD +printf 'func added() int {\n\tif a > b {\n\t\treturn 1\n\t}\n\treturn 0\n}\n' >> src/pkg/x/x.go +# Unchanged file in the same package: its mutants must never count. +git add . && git commit -q -m change + +fixture() { # fixture [] + local extra="" + [ -n "${3:-}" ] && extra=",{\"file_name\":\"doc.go\",\"mutations\":$3}" + printf '{"go_module":"m","files":[{"file_name":"x.go","mutations":%s}%s]}' "$2" "$extra" > "$TMP/$1.json" +} + +run_case() { # run_case + export GREMLINS_FIXTURE="$TMP/$1.json" + export MUTATION_OUT_DIR="$TMP/out-$1" + rm -rf "$MUTATION_OUT_DIR" + output=$(BASE_REF=main bash "$SCRIPT" run 2>&1) + run_rc=$? +} + +echo "added-line ranges" +fixture pass-killed '[{"line":12,"column":5,"type":"CONDITIONALS_BOUNDARY","status":"KILLED"},{"line":3,"column":1,"type":"ARITHMETIC_BASE","status":"SKIPPED"}]' +run_case pass-killed +[ "$run_rc" -eq 0 ] && pass "run phase exits 0" || bad "run phase exit $run_rc" +grep -qx $'src/pkg/x/x.go\t11\t16' "$MUTATION_OUT_DIR/added.tsv" \ + && pass "added.tsv records lines 11-16" || bad "added.tsv: $(cat "$MUTATION_OUT_DIR/added.tsv")" +grep -qx $'src/pkg/x/x.go\t11\t16' "$MUTATION_OUT_DIR/gremlins.tsv" \ + && pass "gremlins.tsv matches for a contiguous append" || bad "gremlins.tsv: $(cat "$MUTATION_OUT_DIR/gremlins.tsv")" +[ -s "$MUTATION_OUT_DIR/errors.tsv" ] && bad "errors.tsv not empty: $(cat "$MUTATION_OUT_DIR/errors.tsv")" || pass "errors.tsv empty" +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = pass ] && pass "verdict pass" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +out_grep -q 'All 1 mutant(s) in changed files were killed' && pass "all-killed summary" || bad "all-killed summary missing" +(cd "$repo" && PR_LABELS= MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict >/dev/null 2>&1) \ + && pass "verdict phase exits 0 on pass" || bad "verdict phase failed on pass" + +echo "nothing mutable in the added lines (#17557 shape)" +fixture nothing '[{"line":3,"column":1,"type":"ARITHMETIC_BASE","status":"SKIPPED"},{"line":7,"column":2,"type":"CONDITIONALS_NEGATION","status":"SKIPPED"}]' +run_case nothing +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = pass ] && pass "skipped-only outside added range is pass" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +out_grep -q 'No mutants in changed files: the 6 added line(s) contain no operator gremlins can mutate (2 mutant(s) on unchanged lines skipped as expected)' \ + && pass "zero-mutant explanation names added and skipped counts" || bad "zero-mutant explanation missing" +out_grep -q 'SKIPPED' && bad "skipped mutants outside the diff must not be listed" || pass "skipped mutants outside the diff are not listed" + +echo "misrouted: SKIPPED inside an added range" +fixture misrouted '[{"line":12,"column":5,"type":"CONDITIONALS_BOUNDARY","status":"SKIPPED"},{"line":12,"column":5,"type":"CONDITIONALS_NEGATION","status":"SKIPPED"},{"line":3,"column":1,"type":"ARITHMETIC_BASE","status":"SKIPPED"}]' +run_case misrouted +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = misrouted ] && pass "verdict misrouted" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +out_grep -q '2 mutant(s) on lines this PR added were SKIPPED' && pass "misrouted count is 2 (line 3 excluded)" || bad "misrouted summary wrong" +out_grep -q '| `src/pkg/x/x.go` | 12 | CONDITIONALS_BOUNDARY |' && pass "misrouted table re-anchored to repo path" || bad "misrouted table missing" +output=$(cd "$repo" && MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 1 ] && out_grep -q '::error::mutation: a mutant on a line this PR added was SKIPPED' \ + && pass "verdict phase exits 1 with ::error on misrouted" || bad "verdict phase rc=$rc: $output" + +echo "lived" +fixture lived '[{"line":12,"column":5,"type":"CONDITIONALS_BOUNDARY","status":"KILLED"},{"line":12,"column":5,"type":"CONDITIONALS_NEGATION","status":"LIVED"},{"line":15,"column":2,"type":"ARITHMETIC_BASE","status":"NOT COVERED"}]' +run_case lived +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = lived ] && pass "lived outranks uncovered" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +out_grep -q '1 surviving mutant(s)' && pass "survivor count" || bad "survivor summary missing" +out_grep -q '| `src/pkg/x/x.go` | 12 | CONDITIONALS_NEGATION |' && pass "survivor row" || bad "survivor row missing" +out_grep -q '1 mutant(s) in changed files are not reached by any test' && pass "uncovered also listed" || bad "uncovered section missing" +output=$(cd "$repo" && MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 1 ] && out_grep -q '::error::mutation: surviving mutant' \ + && pass "verdict phase exits 1 on lived" || bad "verdict phase rc=$rc: $output" +output=$(cd "$repo" && PR_LABELS='mutation/acknowledged' MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 1 ] && pass "mutation/acknowledged does not waive a survivor" || bad "label waived a survivor (rc=$rc)" + +echo "uncovered" +fixture uncovered '[{"line":15,"column":2,"type":"ARITHMETIC_BASE","status":"NOT COVERED"}]' '[{"line":1,"column":1,"type":"ARITHMETIC_BASE","status":"LIVED"}]' +run_case uncovered +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = uncovered ] && pass "verdict uncovered (LIVED in unchanged doc.go ignored)" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +out_grep -q 'doc.go' && bad "unchanged file leaked into the report" || pass "unchanged file not reported" +output=$(cd "$repo" && PR_LABELS='size/S, mutation/acknowledged' MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 0 ] && out_grep -q 'acknowledged via the mutation/acknowledged label' \ + && pass "acknowledged label silences the warning" || bad "acknowledged rc=$rc: $output" +output=$(cd "$repo" && PR_LABELS='size/S' MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 0 ] && out_grep -q '::warning::mutation: mutant(s) in changed files are not reached' \ + && pass "uncovered warns but exits 0" || bad "uncovered rc=$rc: $output" + +echo "error: gremlins exits non-zero and writes no report" +fixture unused '[]' +export GREMLINS_EXIT=1 +run_case gremlins-fails +unset GREMLINS_EXIT +[ "$run_rc" -eq 0 ] && pass "run phase still exits 0" || bad "run phase exit $run_rc" +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = error ] && pass "verdict error" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +grep -qx $'pkg/x\texited 1' "$MUTATION_OUT_DIR/errors.tsv" && pass "errors.tsv names the package and exit code" || bad "errors.tsv: $(cat "$MUTATION_OUT_DIR/errors.tsv")" +out_grep -q '::error::gremlins exited 1 for pkg/x' && pass "run log carries ::error" || bad "run log ::error missing" +out_grep -q 'gremlins did not produce a report for 1 package(s)' && pass "comment reports the failure" || bad "comment failure summary missing" +out_grep -q -- '- `pkg/x`: gremlins exited 1' && pass "comment names the package" || bad "comment package row missing" +out_grep -q 'No mutants in changed files' && bad "false 'nothing to mutate' explanation on a failed run" || pass "no 'nothing to mutate' explanation" +output=$(cd "$repo" && PR_LABELS='mutation/acknowledged' MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 1 ] && out_grep -q '::error::mutation: gremlins failed or wrote no report' \ + && pass "verdict phase exits 1 on error (label does not waive)" || bad "verdict phase rc=$rc: $output" + +echo "error: gremlins exits 0 but writes no report" +export GREMLINS_NO_OUTPUT=1 +run_case gremlins-silent +unset GREMLINS_NO_OUTPUT +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = error ] && pass "verdict error" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +grep -qx $'pkg/x\twrote no report' "$MUTATION_OUT_DIR/errors.tsv" && pass "errors.tsv records the missing report" || bad "errors.tsv: $(cat "$MUTATION_OUT_DIR/errors.tsv")" + +echo "split hunk: non-contiguous added lines sharing one default-context hunk" +# Base x.go is lines 1-10; insert two lines after 3 and two after 7. -U0 adds +# 4-5 and 10-11, but -U3 merges both into @@ -1,10 +1,14 @@ with 3 leading +# context lines, so gremlins v0.6.0 only honours 4-7. +git checkout -q -b split refs/remotes/origin/main +{ for i in 1 2 3; do echo "// line $i"; done; echo 'var a = 1 + 1'; echo 'var b = 2 + 2' + for i in 4 5 6 7; do echo "// line $i"; done; echo 'var c = 3 + 3'; echo 'var d = 4 + 4' + for i in 8 9 10; do echo "// line $i"; done; } > src/pkg/x/x.go +git add . && git commit -q -m split +fixture split '[{"line":4,"column":9,"type":"ARITHMETIC_BASE","status":"KILLED"},{"line":10,"column":9,"type":"ARITHMETIC_BASE","status":"SKIPPED"},{"line":11,"column":9,"type":"ARITHMETIC_BASE","status":"SKIPPED"}]' +run_case split +[ "$(tr '\n' ' ' < "$MUTATION_OUT_DIR/added.tsv")" = $'src/pkg/x/x.go\t4\t5 src/pkg/x/x.go\t10\t11 ' ] \ + && pass "added.tsv records 4-5 and 10-11" || bad "added.tsv: $(cat "$MUTATION_OUT_DIR/added.tsv")" +[ "$(cat "$MUTATION_OUT_DIR/gremlins.tsv")" = $'src/pkg/x/x.go\t4\t7' ] \ + && pass "gremlins.tsv records the honoured approximation 4-7" || bad "gremlins.tsv: $(cat "$MUTATION_OUT_DIR/gremlins.tsv")" +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = pass ] && pass "SKIPPED on added lines gremlins does not honour is not misrouted" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +[ -s "$MUTATION_OUT_DIR/misrouted-changed.tsv" ] && bad "misrouted: $(cat "$MUTATION_OUT_DIR/misrouted-changed.tsv")" || pass "misrouted list empty" +[ "$(wc -l < "$MUTATION_OUT_DIR/unhonoured-changed.tsv" | tr -d ' ')" = 2 ] && pass "two unhonoured mutants recorded" || bad "unhonoured: $(cat "$MUTATION_OUT_DIR/unhonoured-changed.tsv")" +out_grep -q '2 mutant(s) on added lines were SKIPPED because gremlins v0.6.0 only honours' && pass "hunk-approximation note" || bad "hunk-approximation note missing" +out_grep -q '| `src/pkg/x/x.go` | 10 | ARITHMETIC_BASE |' && pass "unhonoured row listed" || bad "unhonoured row missing" +out_grep -q 'All 1 mutant(s) in changed files were killed' && pass "killed summary still shown" || bad "killed summary missing" +(cd "$repo" && MUTATION_OUT_DIR="$MUTATION_OUT_DIR" bash "$SCRIPT" verdict >/dev/null 2>&1) \ + && pass "verdict phase exits 0" || bad "verdict phase failed on split hunk" +fixture split-misrouted '[{"line":4,"column":9,"type":"ARITHMETIC_BASE","status":"SKIPPED"},{"line":10,"column":9,"type":"ARITHMETIC_BASE","status":"SKIPPED"}]' +run_case split-misrouted +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = misrouted ] && pass "SKIPPED inside the honoured range is still misrouted" || bad "verdict $(cat "$MUTATION_OUT_DIR/verdict")" +out_grep -q '1 mutant(s) on lines this PR added were SKIPPED' && pass "misrouted count excludes the unhonoured line" || bad "misrouted summary wrong" + +echo "no changed Go files" +git checkout -q -b docs-only refs/remotes/origin/main +echo x > README.md && git add README.md && git commit -q -m docs +export MUTATION_OUT_DIR="$TMP/out-docs" +output=$(BASE_REF=main bash "$SCRIPT" run 2>&1) +[ "$(cat "$MUTATION_OUT_DIR/verdict")" = pass ] && pass "docs-only PR writes verdict pass" || bad "docs-only verdict: $(cat "$MUTATION_OUT_DIR/verdict" 2>&1)" +output=$(MUTATION_OUT_DIR="$TMP/missing" bash "$SCRIPT" verdict 2>&1); rc=$? +[ "$rc" -eq 1 ] && out_grep -q '::error::mutation: no verdict at' \ + && pass "missing verdict file fails the verdict phase" || bad "missing verdict rc=$rc: $output" + +if [ "$fail" -ne 0 ]; then + echo "test-mutation-report.sh: FAILED" + exit 1 +fi +echo "test-mutation-report.sh: all checks passed" From 3763008e378d29392a7f6d447edff49d7f1f326c Mon Sep 17 00:00:00 2001 From: hive-release-bot Date: Tue, 10 Nov 2026 19:21:01 +0000 Subject: [PATCH 05/69] =?UTF-8?q?=F0=9F=94=96=20release:=20v5.211.20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated release commit. Compiles changelog.d/ fragments and moves the CHANGELOG.md Unreleased section into a dated v5.211.20 entry. See src/docs/releases.md. Signed-off-by: hive-release-bot --- CHANGELOG.md | 6 ++++++ changelog.d/changed-17349-mutation-verdict.md | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 changelog.d/changed-17349-mutation-verdict.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 53351ee8bf..4fbf7e8b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ Hive did not historically maintain a complete changelog. This file starts a prag ## Unreleased +## 2026-11-10 (v5.211.20) + +### Changed + +- CI mutation report (`src/scripts/mutation-report.sh`): the `` PR comment now also lists NOT COVERED mutants in changed files and tells a zero-mutant run apart from a broken one — a SKIPPED mutant on an added line gremlins honours (it only matches the first `lines added` lines of each default-context hunk; the rest are noted, not flagged) is flagged as a diff-matching fault, a gremlins failure or missing report is an `error` verdict rather than a silent pass, while added lines with nothing gremlins can mutate (a unary `!`, a bare `return`) are reported as such instead of "no surviving mutants". A new `verdict` phase exits non-zero on `error`/`lived`/`misrouted` or a missing verdict file and warns on `uncovered` unless the PR carries `mutation/acknowledged`, so a workflow can block on it (#17349, Phase 2). + ## 2026-11-10 (v5.211.19) ### Fixed diff --git a/changelog.d/changed-17349-mutation-verdict.md b/changelog.d/changed-17349-mutation-verdict.md deleted file mode 100644 index 17da3d205a..0000000000 --- a/changelog.d/changed-17349-mutation-verdict.md +++ /dev/null @@ -1 +0,0 @@ -- CI mutation report (`src/scripts/mutation-report.sh`): the `` PR comment now also lists NOT COVERED mutants in changed files and tells a zero-mutant run apart from a broken one — a SKIPPED mutant on an added line gremlins honours (it only matches the first `lines added` lines of each default-context hunk; the rest are noted, not flagged) is flagged as a diff-matching fault, a gremlins failure or missing report is an `error` verdict rather than a silent pass, while added lines with nothing gremlins can mutate (a unary `!`, a bare `return`) are reported as such instead of "no surviving mutants". A new `verdict` phase exits non-zero on `error`/`lived`/`misrouted` or a missing verdict file and warns on `uncovered` unless the PR carries `mutation/acknowledged`, so a workflow can block on it (#17349, Phase 2). From 0203420fc035f0ec888319eb99fb21b07031f9b2 Mon Sep 17 00:00:00 2001 From: Andy Anderson Date: Tue, 10 Nov 2026 14:30:43 -0500 Subject: [PATCH 06/69] =?UTF-8?q?=F0=9F=90=9B=20Honor=20every=20configured?= =?UTF-8?q?=20trusted=20bot=20in=20the=20trusted-bot=20automerge=20lane=20?= =?UTF-8?q?(#17578)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PRs authored by a login in auto_merge.trusted_bot_authors (Settings bot toggles or a custom login) were evaluated by the trusted-bot lane but held on the review swarm's requires_human verdict and parked at "needs a person", while the contributor lane logged them as app-authored and the self-authored sweep's skip/hold lines carried no tier. - The swarm verdict is advisory on the trusted-bot lane by default (auto_merge.trusted_bot_skip_review, default true): recorded on the evidence bundle, never a hold or an 085 stage. - The contributor lane hands trusted bots off as trusted-bot-lane; every self-authored sweep skip/hold line carries tier=. - A config-named required check that never reported on the repo gates on the other reported checks (one warning per repo per hour) or holds with required-check-never-reported:, shown on the Activity Monitor as the human-gate reason. Fixes #17577 Signed-off-by: Andrew Anderson Co-authored-by: hivecommons-hive[bot] <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-trusted-bot-lane-dependabot.md | 1 + src/cmd/hive/main.go | 1 + src/cmd/hive/main_sweeps.go | 2 + src/docs/hive-merge.md | 23 ++ src/docs/operator-reference/README.md | 1 + src/pkg/config/config.go | 15 + src/pkg/dashboard/api_config_automerge.go | 8 + src/pkg/dashboard/stage_tracker_caption.go | 3 + .../automerge/automerge_base_preparation.go | 2 +- .../automerge/automerge_contributor_lane.go | 11 +- .../github/automerge/automerge_held_runs.go | 2 +- .../github/automerge/automerge_review_gate.go | 4 +- .../automerge/automerge_review_gate_test.go | 4 + src/pkg/github/automerge/automerge_sweep.go | 8 + .../github/automerge/automerge_sweep_loop.go | 15 +- .../automerge/automerge_sweep_trusted.go | 18 +- .../automerge/automerge_trusted_bot_lane.go | 156 +++++++++ .../automerge_trusted_bot_lane_test.go | 315 ++++++++++++++++++ src/pkg/github/commit_ci.go | 6 + src/pkg/stageengine/derive_pr_classify.go | 7 + src/pkg/stageengine/prstage/reasons.go | 5 + 21 files changed, 594 insertions(+), 13 deletions(-) create mode 100644 changelog.d/fixed-trusted-bot-lane-dependabot.md create mode 100644 src/pkg/github/automerge/automerge_trusted_bot_lane.go create mode 100644 src/pkg/github/automerge/automerge_trusted_bot_lane_test.go diff --git a/changelog.d/fixed-trusted-bot-lane-dependabot.md b/changelog.d/fixed-trusted-bot-lane-dependabot.md new file mode 100644 index 0000000000..b2d645de1c --- /dev/null +++ b/changelog.d/fixed-trusted-bot-lane-dependabot.md @@ -0,0 +1 @@ +- Trusted-bot automerge lane: PRs from every login the operator enabled under `auto_merge.trusted_bot_authors` (Settings bot toggles or a custom login) are now honored by the trusted-bot lane end to end. The review swarm's verdict is advisory for them by default (`auto_merge.trusted_bot_skip_review`, default `true`), so a Dependabot bump a reviewer routed to `requires_human` no longer parks at "needs a person" while its checks are green; the contributor lane hands bot PRs off as `trusted-bot-lane` instead of `contributor-lane:app-authored`; every self-authored-sweep skip/hold line carries `tier`; and when `auto_merge.required_checks` names a check a repo never runs, the lane gates on the checks that do report (warning once per repo per hour) or holds with `required-check-never-reported:`, which the Activity Monitor shows as the human-gate reason (#17577). diff --git a/src/cmd/hive/main.go b/src/cmd/hive/main.go index a26dd7992e..10020705b9 100644 --- a/src/cmd/hive/main.go +++ b/src/cmd/hive/main.go @@ -2217,6 +2217,7 @@ func (b *boot) bootAgentsWith(deps bootAgentsDeps) { // Read through b.cfg on every sweep tick so a config reload of // auto_merge.trusted_bot_authors takes effect without a restart. autoMergeOpts.TrustedBotAuthors = func() map[string]bool { return b.cfg.AutoMerge.TrustedBotAuthorSet() } + autoMergeOpts.TrustedBotSkipReview = func() bool { return b.cfg.AutoMerge.TrustedBotSkipsReview() } autoMergeOpts.BotTakeoverEnabled = func() bool { return b.cfg.AutoMerge.BotTakeover.IsEnabled() } // Intent tier gate (#6258): the human lane only queues PRs that // survive writeMergeEligible's intent check, but this sweep lists diff --git a/src/cmd/hive/main_sweeps.go b/src/cmd/hive/main_sweeps.go index 0ffdd1eda0..35f0474ab3 100644 --- a/src/cmd/hive/main_sweeps.go +++ b/src/cmd/hive/main_sweeps.go @@ -895,6 +895,7 @@ func runAutoMergeSweepIfDue(ctx context.Context, ghClient *github.Client, cfg *c return automerge.MergeTrainPolicy{Enabled: cfg.AutoMerge.MergeTrain.IsEnabled(), MaxRebaseAttempts: cfg.AutoMerge.MergeTrain.EffectiveMaxRebaseAttempts()} } opts.TrustedBotAuthors = func() map[string]bool { return cfg.AutoMerge.TrustedBotAuthorSet() } + opts.TrustedBotSkipReview = func() bool { return cfg.AutoMerge.TrustedBotSkipsReview() } opts.NativeMergeQueue = func() automerge.NativeMergeQueuePolicy { q := cfg.AutoMerge.NativeMergeQueue return automerge.NativeMergeQueuePolicy{Enabled: q.Enabled, Repos: q.RepoSet(), Bases: q.BaseSet(), SkipCurrentBaseGate: q.SkipCurrentBaseGate, ProbeTTL: q.EffectiveProbeTTL()} @@ -1487,6 +1488,7 @@ func runIssueUnparkSweepIfDue(ctx context.Context, ghClient *github.Client, cfg approveOpts.HumanMergePinOnly = func(repo string) (config.PinOnlyException, bool) { return humanMergePinOnlyFor(cfg, repo) } approveOpts.HumanMergeRule = func() prstage.HumanMergeRule { return humanMergeRuleFor(cfg) } approveOpts.TrustedBotAuthors = func() map[string]bool { return cfg.AutoMerge.TrustedBotAuthorSet() } + approveOpts.TrustedBotSkipReview = func() bool { return cfg.AutoMerge.TrustedBotSkipsReview() } } approveEngine := automerge.New(ghClient, approveOpts) result, err := ghClient.SweepIssueUnparkCommands(ctx, github.IssueUnparkSweepOptions{ diff --git a/src/docs/hive-merge.md b/src/docs/hive-merge.md index 38b0e49504..53427fe798 100644 --- a/src/docs/hive-merge.md +++ b/src/docs/hive-merge.md @@ -438,6 +438,29 @@ underlying endpoint is `GET/PUT /api/config/auto-merge` (owner-only), whose response carries `bot_authors: [{login, source: known|discovered|custom, trusted}]`. +Every login on that list — a Settings toggle or a typed-in custom bot — is +owned by the trusted-bot lane: the contributor lane hands it off as +`trusted-bot-lane` (never `contributor-lane:app-authored`), and every +`automerge skip` / `automerge hold` line the self-authored sweep logs carries +`tier=trusted-bot` so a stuck bot PR can be grepped by lane. The lane's +contract is "safety is established by CI", so the review swarm's verdict on +a trusted bot's PR is **advisory** by default: a `requires_human`, +decision-requested or `changes_requested` verdict is recorded on the +evidence bundle and logged (`trusted-bot lane: review verdict advisory`) +but neither holds the merge nor parks the PR at "needs a person". Set +`auto_merge.trusted_bot_skip_review: false` to make bot PRs obey the swarm +exactly like the App's own; a trusted human's `changes_requested` review +always holds regardless. When `auto_merge.required_checks` names a check +the repo never produces (for example `build-gate` declared hive-wide but +absent on a docs repo), the lane does not wait forever: if at least one +other check reports on the head and none is red or still running, it merges +on "every reported check green" and warns once per repo per hour +(`trusted-bot lane: required check "build-gate" never reported on +/`); if nothing else reports, the PR is held with +`required-check-never-reported:`, which the Activity Monitor shows as +the human-gate reason. Declare the repo's real set under +`auto_merge.repos..required_checks` to clear either condition. + ### Event-driven sweeps on the ForgeState cache With `forgestate.enabled: true` the three sweep lanes (self-authored, diff --git a/src/docs/operator-reference/README.md b/src/docs/operator-reference/README.md index 90aa45ecdb..4e2ec10d20 100644 --- a/src/docs/operator-reference/README.md +++ b/src/docs/operator-reference/README.md @@ -498,6 +498,7 @@ advanced into the merge path. | `auto_merge.hive_superseding.auto_merge` | `true` | Owner rule: a PR the hive App itself opened to supersede another PR (`Supersedes #N` in its body — takeover, close-first adoption, re-author) auto-merges with no operator decision. A reviewer `requires_human`, security-sensitive included, is routed to the fixer as `changes_requested` instead of parking at `stage/085`; the head merges through the hive-authored lane once CI and review are clean. The only stops are an unacknowledged sentinel finding, a hold, exhausted fix attempts (CI still red / base still conflicting), or a conflict the hive already failed to rebase twice — each named in the 085 caption as `hive-superseder-hard-stop:`. `false` restores the old park. See [hive-merge.md](../hive-merge.md#hive-authored-superseding-prs-auto-merge). | | `auto_merge.squash_only` | unset (no repo) | Repo list (`owner/repo`) whose branch policy forbids merge commits. Elsewhere, a `role/trusted` PR whose head mixes the contributor's commits with App-linked, App-signed ones (the hive's own in-place adoption fixes), every commit self-signed, is labelled `merge-method/merge` and merged with a merge commit instead of parking at `stage/085` as `adoption-stalled:hive-signoff-attribution`; a listed repo keeps squash-only policy and re-homes an in-place adoption to an App-authored superseder instead (#13975). | | `auto_merge.credit_issue_authors` | `true` | Append `Co-authored-by: ` for the human authors of the issues a PR closes (`Fixes|Closes|Resolves #N`) to the squash (or merge) commit message on every hive-performed merge, so reporters land on the contributor graph when an external clanker fixed their issue. Bots, the PR author and logins already credited on the branch are skipped; the logins are recorded as `issue_authors=` on the merge audit entry and in review evidence. One cached `GET /issues/{n}` per newly referenced issue. `false` leaves GitHub's default squash message untouched (#14581). | +| `auto_merge.trusted_bot_skip_review` | `true` | The review swarm's verdict is advisory for PRs authored by a `trusted_bot_authors` login: a `requires_human` / `changes_requested` verdict is recorded but never holds the merge or routes the PR to "needs a person" — the lane's safety is the repo's CI. Set `false` to make bot PRs obey the swarm like the App's own. See [hive-merge.md](../hive-merge.md#trusted-bot-authors). | | `auto_merge.bot_takeover.enabled` | `true` | When `github-actions[bot]` is in `auto_merge.trusted_bot_authors`, re-author its same-repo PRs whose required `pull_request` checks can never run (the bot opened them with a workflow `GITHUB_TOKEN`). After the head is older than both `min_head_age` and 30 minutes with no `pull_request` run, the App pushes the same change as one signed-off commit to `hive/takeover-`, opens a PR with the original title/body plus `Supersedes #`, comments `Superseded by #N` on the bot PR and closes it. One attempt per bot head SHA. See [hive-merge.md](../hive-merge.md#github-actionsbot-pr-takeover). | | `auto_merge.trusted_authors.enabled` | `false` | Enables the opt-in human-authored PR tier: Hive may merge a green PR only when the author already holds the required hive role and, by default, GitHub push/maintain/admin permission on that repo. | | `auto_merge.trusted_authors.repos` | empty = all watched repos | Optional repo allow-list for the trusted-author tier. The dashboard renders this as a watched-repo multi-select; selecting nothing preserves the all-repos default. | diff --git a/src/pkg/config/config.go b/src/pkg/config/config.go index 96b71636ef..d6c14279ac 100644 --- a/src/pkg/config/config.go +++ b/src/pkg/config/config.go @@ -8591,6 +8591,14 @@ type AutoMergeConfig struct { // (`trusted_bot_authors: []`) disables the lane. Matched case-insensitively // by exact login, e.g. "dependabot[bot]". TrustedBotAuthors []string `yaml:"trusted_bot_authors,omitempty" json:"trusted_bot_authors,omitempty"` + // TrustedBotSkipReview makes the review swarm's verdict advisory for PRs + // authored by a TrustedBotAuthors login. The trusted-bot lane's contract + // is "safety is established by CI": a dependency bump a reviewer routed + // to requires_human must not park at "needs a person" when its required + // checks are green. nil/unset means true; set false to let a + // requires_human / changes_requested swarm verdict hold trusted-bot PRs + // exactly like the App's own. + TrustedBotSkipReview *bool `yaml:"trusted_bot_skip_review,omitempty" json:"trusted_bot_skip_review,omitempty"` // BotTakeover lets the sweep re-author a trusted `github-actions[bot]` PR // whose required `pull_request` checks can never run because the bot // opened it with a workflow GITHUB_TOKEN (#12003). The App pushes the @@ -9162,6 +9170,13 @@ func (a AutoMergeConfig) TrustedBotAuthorSet() map[string]bool { return set } +// TrustedBotSkipsReview reports whether the review swarm's verdict is +// advisory for trusted-bot lane PRs (auto_merge.trusted_bot_skip_review, +// default true). +func (a AutoMergeConfig) TrustedBotSkipsReview() bool { + return a.TrustedBotSkipReview == nil || *a.TrustedBotSkipReview +} + func (t TrustedAuthorAutoMergeConfig) EffectiveRequireRole() string { role := strings.ToLower(strings.TrimSpace(t.RequireRole)) if role == "" { diff --git a/src/pkg/dashboard/api_config_automerge.go b/src/pkg/dashboard/api_config_automerge.go index 8665e5e5c5..cb96f7935c 100644 --- a/src/pkg/dashboard/api_config_automerge.go +++ b/src/pkg/dashboard/api_config_automerge.go @@ -157,6 +157,9 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) { // TrustedBotAuthors is the FULL desired list; an empty (non-nil) list // disables the trusted-bot lane, absent leaves it untouched. TrustedBotAuthors []string `json:"trusted_bot_authors"` + // TrustedBotSkipReview is auto_merge.trusted_bot_skip_review: the + // review swarm's verdict is advisory on the trusted-bot lane. + TrustedBotSkipReview *bool `json:"trusted_bot_skip_review"` // BotTakeoverEnabled is auto_merge.bot_takeover.enabled; flat so the // dialog's plain toggle can stage it. BotTakeoverEnabled *bool `json:"bot_takeover_enabled"` @@ -319,6 +322,10 @@ func (s *Server) handleAutoMergePut(w http.ResponseWriter, r *http.Request) { if body.TrustedBotAuthors != nil { cfg.AutoMerge.TrustedBotAuthors = normalizeBotLoginList(body.TrustedBotAuthors) } + if body.TrustedBotSkipReview != nil { + v := *body.TrustedBotSkipReview + cfg.AutoMerge.TrustedBotSkipReview = &v + } if body.BotTakeoverEnabled != nil { v := *body.BotTakeoverEnabled cfg.AutoMerge.BotTakeover.Enabled = &v @@ -453,6 +460,7 @@ func autoMergeSectionResponse(cfg *config.Config) map[string]interface{} { "no_ci_ok": noCIOK, "trusted_bot_authors": trustedBots, "trusted_bot_authors_set": am.TrustedBotAuthors != nil, + "trusted_bot_skip_review": am.TrustedBotSkipsReview(), "bot_takeover_enabled": am.BotTakeover.IsEnabled(), "require_current_base_default": am.CurrentBaseDefaultEnabled(), "require_current_base": emptyIfNilStrings(am.RequireCurrentBase), diff --git a/src/pkg/dashboard/stage_tracker_caption.go b/src/pkg/dashboard/stage_tracker_caption.go index 7b9fc8930b..e84d248492 100644 --- a/src/pkg/dashboard/stage_tracker_caption.go +++ b/src/pkg/dashboard/stage_tracker_caption.go @@ -417,6 +417,9 @@ func humanizeStageReason(reason string) string { if rest, ok := strings.CutPrefix(r, stageengineprstage.StageReasonUnauthorizedPrefix); ok { return "the hive's GitHub App is not permitted to " + unauthorizedStepWords(rest) + "; a maintainer must" } + if rest, ok := strings.CutPrefix(r, stageengineprstage.RequiredCheckNeverReportedPrefix); ok { + return "required check " + rest + " has never reported on this repository — fix auto_merge.required_checks (or the repo's required_checks override) or merge by hand" + } if rest, ok := strings.CutPrefix(r, "fork-guard:"); ok { return "check " + strings.ReplaceAll(rest, ",", ", ") + " refuses fork PRs — a maintainer must push this branch to the repository" } diff --git a/src/pkg/github/automerge/automerge_base_preparation.go b/src/pkg/github/automerge/automerge_base_preparation.go index 2ca2726ca9..16931b1c36 100644 --- a/src/pkg/github/automerge/automerge_base_preparation.go +++ b/src/pkg/github/automerge/automerge_base_preparation.go @@ -301,7 +301,7 @@ func preparationKeepsOwner(reason string, err error) bool { return true } // Another lane declining authorship is not the owning lane withdrawing. - return reason == "not-app-authored" || reason == trustedAuthorReasonAppAuthored || reason == contributorLaneReasonAppAuthored + return reason == "not-app-authored" || reason == trustedAuthorReasonAppAuthored || reason == contributorLaneReasonAppAuthored || reason == trustedBotLaneSkipReason } func (c *Engine) observeBasePreparation(lane, owner, repo string, pr *gh.PullRequest, reason string, merged bool, evalErr error) { diff --git a/src/pkg/github/automerge/automerge_contributor_lane.go b/src/pkg/github/automerge/automerge_contributor_lane.go index 7810eed186..72ee6aa15a 100644 --- a/src/pkg/github/automerge/automerge_contributor_lane.go +++ b/src/pkg/github/automerge/automerge_contributor_lane.go @@ -522,8 +522,13 @@ func (c *Engine) prefilterContributorLanePR(pr *gh.PullRequest, policy Contribut return contributorLaneReasonNoAuthor } // The App's own PRs and allow-listed bots belong to the self-authored - // lane; a claim marker can never make them contributor work. - if _, ok := c.sweepLaneForAuthor(author); ok { + // lane; a claim marker can never make them contributor work. A trusted + // bot is handed off under its own reason so the log names the lane that + // owns it rather than calling the operator's bot "app-authored". + if lane, ok := c.sweepLaneForAuthor(author); ok { + if lane == laneTrustedBot { + return trustedBotLaneSkipReason + } return contributorLaneReasonAppAuthored } // author_association is deliberately not checked here: a verified claim @@ -1341,7 +1346,7 @@ func (c *Engine) evaluateContributorLanePR(ctx context.Context, displayRepo, own } c.noteStagePR(owner, repo, number, pr) if reason := c.sentinelBlockedUnlessHumanChangesRequested(caller, owner, repo, pr, c.prefilterContributorLanePR(pr, policy)); reason != "" { - if reason == contributorLaneReasonAppAuthored { + if reason == contributorLaneReasonAppAuthored || reason == trustedBotLaneSkipReason { c.noteStageRole(owner, repo, number, stagelabels.RoleTrusted) } else { c.noteRegistryRole(owner, repo, number, hgithub.SafeGetLogin(pr.GetUser()), policy) diff --git a/src/pkg/github/automerge/automerge_held_runs.go b/src/pkg/github/automerge/automerge_held_runs.go index 42363bca74..0a27335a11 100644 --- a/src/pkg/github/automerge/automerge_held_runs.go +++ b/src/pkg/github/automerge/automerge_held_runs.go @@ -589,7 +589,7 @@ func headOlderThan(now func() time.Time, headPushedAt time.Time, grace time.Dura // isTerminalRequiredCheckHold reports whether reason is a hold polling cannot // cure (held for approval, runs never created, or never-ran after a nudge). func isTerminalRequiredCheckHold(reason string) bool { - return strings.HasPrefix(reason, workflowApprovalRequiredPrefix) || strings.HasPrefix(reason, requiredCheckNeverStartedPrefix) || strings.HasPrefix(reason, requiredCheckNeverRanPrefix) + return strings.HasPrefix(reason, workflowApprovalRequiredPrefix) || strings.HasPrefix(reason, requiredCheckNeverStartedPrefix) || strings.HasPrefix(reason, requiredCheckNeverRanPrefix) || strings.HasPrefix(reason, requiredCheckNeverReportedPrefix) } // isAutofixPushedDependabotHead reports whether pr is a trusted-lane diff --git a/src/pkg/github/automerge/automerge_review_gate.go b/src/pkg/github/automerge/automerge_review_gate.go index f2227a15a2..3cef256a66 100644 --- a/src/pkg/github/automerge/automerge_review_gate.go +++ b/src/pkg/github/automerge/automerge_review_gate.go @@ -247,7 +247,9 @@ func (c *Engine) mergeReviewGate(ctx context.Context, displayRepo, owner, repo, verdict = gate.Verdict(fullRepo, number, head) } outcome := reviewGateOutcome(verdict) - enforce := mode == ReviewGateModeEnforce + // The trusted-bot lane records the swarm verdict but never holds on it + // while auto_merge.trusted_bot_skip_review is on: CI is its safety gate. + enforce := mode == ReviewGateModeEnforce && !c.trustedBotReviewAdvisory(lane) humanApprover, overrode := "", "" if enforce && outcome != ReviewGateOutcomeApproved { // A trusted human's APPROVED review on exactly this head outranks diff --git a/src/pkg/github/automerge/automerge_review_gate_test.go b/src/pkg/github/automerge/automerge_review_gate_test.go index 827a683ffa..a93ccce4bd 100644 --- a/src/pkg/github/automerge/automerge_review_gate_test.go +++ b/src/pkg/github/automerge/automerge_review_gate_test.go @@ -338,6 +338,10 @@ func TestMergeReviewGateCoversEveryLane(t *testing.T) { Mode: func() string { return ReviewGateModeEnforce }, Verdict: func(string, int, string) ReviewGateVerdict { asked++; return reviewGateNoBundle }, }, &rec) + // The trusted-bot lane only holds on the swarm when the operator + // turned auto_merge.trusted_bot_skip_review off (default on: + // advisory, see automerge_trusted_bot_lane_test.go). + c.trustedBotSkipReview = func() bool { return false } reason := c.mergeReviewGate(context.Background(), "acme/widget", "acme", "widget", tt.lane, 7, nil, "sha7", "", false) if want := autoMergeReasonReviewGatePrefix + ReviewGateOutcomeNoBundle; reason != want || asked != 1 { t.Fatalf("lane %s: reason = %q asked = %d; want %q held once", tt.lane, reason, asked, want) diff --git a/src/pkg/github/automerge/automerge_sweep.go b/src/pkg/github/automerge/automerge_sweep.go index bd02d619f6..e0afef2944 100644 --- a/src/pkg/github/automerge/automerge_sweep.go +++ b/src/pkg/github/automerge/automerge_sweep.go @@ -152,6 +152,10 @@ type Options struct { // PRs the self-authored sweep merges alongside the App's own (see // config.AutoMergeConfig.TrustedBotAuthors). nil means App-only. TrustedBotAuthors func() map[string]bool + // TrustedBotSkipReview returns the live auto_merge.trusted_bot_skip_review + // switch: the review swarm's verdict is advisory on the trusted-bot lane + // (config.AutoMergeConfig.TrustedBotSkipsReview). nil means true. + TrustedBotSkipReview func() bool // BotTakeoverEnabled returns the live auto_merge.bot_takeover.enabled // switch: re-author a trusted github-actions[bot] PR whose // `pull_request` checks can never run (#12003). nil means off. @@ -348,6 +352,7 @@ type Engine struct { repoAutoMergeEnabled func(repo string) bool repoOnGitHub func(repo string) bool trustedBotAuthors func() map[string]bool + trustedBotSkipReview func() bool botTakeoverEnabledFn func() bool trustedAuthorPolicy func() TrustedAuthorPolicy trustedAuthorizer TrustedAuthorizer @@ -365,6 +370,7 @@ type Engine struct { evaluatedHeads map[string]string requiredChecksFallbackWarnedMu sync.Mutex requiredChecksFallbackWarned map[string]bool + requiredCheckNeverReportedWarned map[string]time.Time // heldRunApprovals is the shared per-PR-head one-shot map for rebase // nudges and bot takeovers (historic name; workflow approvals no longer use it). heldRunApprovalsMu sync.Mutex @@ -460,6 +466,7 @@ func New(transport Transport, opts Options) *Engine { repoAutoMergeEnabled: opts.RepoAutoMergeEnabled, repoOnGitHub: opts.RepoOnGitHub, trustedBotAuthors: opts.TrustedBotAuthors, + trustedBotSkipReview: opts.TrustedBotSkipReview, rateLimitCautious: opts.RateLimitCautious, botTakeoverEnabledFn: opts.BotTakeoverEnabled, trustedAuthorPolicy: opts.TrustedAuthorPolicy, @@ -494,6 +501,7 @@ func New(transport Transport, opts Options) *Engine { integrationFilesObserved: opts.IntegrationFilesObserved, evaluatedHeads: make(map[string]string), requiredChecksFallbackWarned: make(map[string]bool), + requiredCheckNeverReportedWarned: make(map[string]time.Time), } if e.now == nil { e.now = time.Now diff --git a/src/pkg/github/automerge/automerge_sweep_loop.go b/src/pkg/github/automerge/automerge_sweep_loop.go index 9626c2f2a3..636a529c9b 100644 --- a/src/pkg/github/automerge/automerge_sweep_loop.go +++ b/src/pkg/github/automerge/automerge_sweep_loop.go @@ -202,6 +202,9 @@ func (c *Engine) SweepSelfAuthoredAutoMerges(ctx context.Context, opts AutoMerge c.reconcileNativeQueueGate(ctx, stageLaneSelf, owner, repoName, pr, reason) c.recordStage(stageLaneSelf, repo, owner, repoName, pr, reason, merged, err) } + // tier names the lane on every skip/hold line so an operator can + // grep a trusted bot's PR by `"tier":"trusted-bot"`. + tier := c.selfAuthoredSweepTier(pr) if _, held := train.duplicateOf(number); held { result.Skipped++ repoSkipped++ @@ -224,7 +227,7 @@ func (c *Engine) SweepSelfAuthoredAutoMerges(ctx context.Context, opts AutoMerge continue } if reason, handled := c.mergeTrainFront(ctx, train, pr); handled { - c.info("automerge skip", "repo", repo, "pr", number, "reason", reason) + c.info("automerge skip", "repo", repo, "pr", number, "reason", reason, "tier", tier) result.Skipped++ repoSkipped++ repoSkipReasons[autoMergeReasonMergeTrainRebasing]++ @@ -282,9 +285,9 @@ func (c *Engine) SweepSelfAuthoredAutoMerges(ctx context.Context, opts AutoMerge } if reason := c.detectTrustedRegistryClankerWorkflowApprovalRequired(ctx, repo, owner, repoName, pr); reason != "" { if isTerminalRequiredCheckHold(reason) { - c.info("automerge hold", "repo", repo, "pr", number, "sha", pr.GetHead().GetSHA(), "reason", reason) + c.info("automerge hold", "repo", repo, "pr", number, "sha", pr.GetHead().GetSHA(), "reason", reason, "tier", tier) } else { - c.info("automerge skip", "repo", repo, "pr", number, "reason", reason) + c.info("automerge skip", "repo", repo, "pr", number, "reason", reason, "tier", tier) } result.Skipped++ repoSkipped++ @@ -293,7 +296,7 @@ func (c *Engine) SweepSelfAuthoredAutoMerges(ctx context.Context, opts AutoMerge continue } if reason := c.prefilterSelfAuthoredPR(pr); reason != "" { - c.info("automerge skip", "repo", repo, "pr", number, "reason", reason) + c.info("automerge skip", "repo", repo, "pr", number, "reason", reason, "tier", tier) result.Skipped++ repoSkipped++ repoSkipReasons[reason]++ @@ -323,10 +326,10 @@ func (c *Engine) SweepSelfAuthoredAutoMerges(ctx context.Context, opts AutoMerge if reason != "" { if isTerminalRequiredCheckHold(reason) || isPermanentMergeRefusal(reason) { if c.markTerminalHoldLogged(owner, repoName, number, pr.GetHead().GetSHA(), reason) { - c.info("automerge hold", "repo", repo, "pr", number, "sha", pr.GetHead().GetSHA(), "reason", reason) + c.info("automerge hold", "repo", repo, "pr", number, "sha", pr.GetHead().GetSHA(), "reason", reason, "tier", tier) } } else { - c.info("automerge skip", "repo", repo, "pr", number, "reason", reason) + c.info("automerge skip", "repo", repo, "pr", number, "reason", reason, "tier", tier) } result.Skipped++ repoSkipped++ diff --git a/src/pkg/github/automerge/automerge_sweep_trusted.go b/src/pkg/github/automerge/automerge_sweep_trusted.go index 730e06c33b..2bbb550238 100644 --- a/src/pkg/github/automerge/automerge_sweep_trusted.go +++ b/src/pkg/github/automerge/automerge_sweep_trusted.go @@ -102,6 +102,9 @@ func (c *Engine) trySweepSelfAuthoredPR(ctx context.Context, displayRepo, owner, } c.noteStageRole(owner, repo, number, stagelabels.RoleTrusted) verdict := c.contributorLaneVerdictFor(owner+"/"+repo, number, evaluatedHeadSHA) + // Trusted-bot lane: the swarm verdict is advisory (safety is the repo's + // CI), so a requires_human on a dependency bump never derives 085. + verdict = c.trustedBotLaneVerdict(displayRepo, number, evaluatedHeadSHA, lane, verdict) c.noteStageVerdict(owner, repo, number, verdict) priorApprover, _ := c.trustedHumanApprovalForRequiresHuman(ctx, owner, repo, number, evaluatedHeadSHA, verdict) priorChecked := verdictNeedsHuman(stageDetail{Verdict: verdict, VerdictKnown: true}) @@ -150,7 +153,8 @@ func (c *Engine) trySweepSelfAuthoredPR(ctx context.Context, displayRepo, owner, return AutoMergeSweepEvent{}, reason, nil } headPushedAt := c.headPushedAt(ctx, owner, repo, number, evaluatedHeadSHA, pr) - green, reason, err := c.commitGreenForPR(ctx, owner, repo, baseBranch, evaluatedHeadSHA, number, headPushedAt, expectedCheckCacheFromContext(ctx)) + ciState, _, err := c.commitCIForPRSkipping(ctx, owner, repo, baseBranch, evaluatedHeadSHA, number, headPushedAt, expectedCheckCacheFromContext(ctx), nil) + green, reason := ciState.Green, ciState.Reason if err != nil { return AutoMergeSweepEvent{}, reason, err } @@ -168,6 +172,18 @@ func (c *Engine) trySweepSelfAuthoredPR(ctx context.Context, displayRepo, owner, return AutoMergeSweepEvent{}, reason, err } } + if !green { + // auto_merge.required_checks may name a check this repo never runs + // (automerge_trusted_bot_lane.go): gate on the checks that do report, + // or surface the absent check by name. + green, reason, err = c.recheckRequiredCheckNeverReported(ctx, displayRepo, owner, repo, baseBranch, pr, number, evaluatedHeadSHA, headPushedAt, ciState, reason) + if err != nil { + return AutoMergeSweepEvent{}, reason, err + } + if strings.HasPrefix(reason, requiredCheckNeverReportedPrefix) { + return AutoMergeSweepEvent{}, reason, nil + } + } if !green { // A missing required check on a trusted-lane head may be a workflow // run GitHub is holding for approval; post /ok-to-test and surface it diff --git a/src/pkg/github/automerge/automerge_trusted_bot_lane.go b/src/pkg/github/automerge/automerge_trusted_bot_lane.go new file mode 100644 index 0000000000..1fce8dd094 --- /dev/null +++ b/src/pkg/github/automerge/automerge_trusted_bot_lane.go @@ -0,0 +1,156 @@ +package automerge + +// The trusted-bot lane merges PRs authored by the logins the operator enabled +// under auto_merge.trusted_bot_authors (Settings → bot toggles, any custom +// login). Its contract is "safety is established by CI": the review swarm's +// verdict is advisory unless the operator turns +// auto_merge.trusted_bot_skip_review off, and a required check that +// auto_merge.required_checks names but the repo has never produced is +// surfaced by name instead of parking the PR at a bare "needs a person". + +import ( + "context" + "strings" + "time" + + gh "github.com/google/go-github/v72/github" + + hgithub "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stageengine/prstage" +) + +const ( + // laneTrustedBot is the sweepLaneForAuthor lane for TrustedBotAuthors. + laneTrustedBot = "trusted-bot" + // requiredCheckNeverReportedPrefix: see prstage.RequiredCheckNeverReportedPrefix. + requiredCheckNeverReportedPrefix = prstage.RequiredCheckNeverReportedPrefix + // requiredCheckNeverReportedWarnEvery bounds the operator warning to one + // line per repo per check per hour. + requiredCheckNeverReportedWarnEvery = time.Hour + // trustedBotAdvisoryVerdict is what the stage tracker records in place of + // a swarm verdict the trusted-bot lane treats as advisory. + trustedBotAdvisoryVerdict = "advisory" +) + +// trustedBotReviewAdvisory reports whether the review swarm's verdict is +// advisory on lane: only the trusted-bot lane, and only while +// auto_merge.trusted_bot_skip_review is on (the default). +func (c *Engine) trustedBotReviewAdvisory(lane string) bool { + if c == nil || lane != laneTrustedBot { + return false + } + return c.trustedBotSkipReview == nil || c.trustedBotSkipReview() +} + +// trustedBotLaneVerdict downgrades a swarm verdict that would hold or route +// a trusted-bot PR to a person (requires_human, decision-requested, +// changes_requested, reject) to an advisory one. The verdict itself stays +// visible: the review comment is on the PR and the downgrade is logged once +// per evaluation. Verdicts a person already answered are left alone. +func (c *Engine) trustedBotLaneVerdict(displayRepo string, number int, head, lane string, v ContributorLaneVerdict) ContributorLaneVerdict { + if !c.trustedBotReviewAdvisory(lane) || !v.Configured || v.Approved || v.DecisionAnswered { + return v + } + d := stageDetail{Verdict: v, VerdictKnown: true} + if !verdictNeedsHuman(d) && !verdictBlocks(d) { + return v + } + original := strings.ToLower(strings.TrimSpace(v.Verdict)) + if original == "" && v.DecisionRequested { + original = "decision-requested" + } + c.info("trusted-bot lane: review verdict advisory", "tier", lane, "repo", displayRepo, "pr", number, "head", head, "verdict", original, "reason", "trusted_bot_skip_review") + v.Verdict = trustedBotAdvisoryVerdict + v.DecisionRequested = false + v.DecisionQuestion = "" + v.DecisionFinding = "" + v.FixCycleCapReached = false + return v +} + +// recheckRequiredCheckNeverReported re-evaluates a `required-check-missing:` +// head on the trusted-bot lane when the required set came from +// auto_merge.required_checks and the named check has never reported on this +// head: the config names a check this repo does not run (e.g. "build-gate" +// declared for console, absent on docs). With at least one other check +// reporting and none red, the head is gated on "every reported check green" +// instead; with nothing else to vouch for it, the hold is surfaced as +// required-check-never-reported: so the human gate names the cause. +// Both outcomes log once per repo per check per hour. The verdict is +// returned unchanged when the shape does not apply. +func (c *Engine) recheckRequiredCheckNeverReported(ctx context.Context, displayRepo, owner, repo, branch string, pr *gh.PullRequest, number int, headSHA string, headPushedAt time.Time, ci hgithub.CommitCIState, reason string) (bool, string, error) { + if c == nil || !strings.HasPrefix(reason, requiredCheckMissingPrefix) || !ci.RequiredFromConfig || len(ci.MissingRequired) == 0 { + return false, reason, nil + } + if lane, ok := c.sweepLaneForAuthor(hgithub.SafeGetLogin(pr.GetUser())); !ok || lane != laneTrustedBot { + return false, reason, nil + } + missing := make(map[string]bool, len(ci.MissingRequired)) + for _, name := range ci.MissingRequired { + missing[name] = true + } + observedOther := 0 + for name := range ci.Observed { + if !missing[name] { + observedOther++ + } + } + first := ci.MissingRequired[0] + if observedOther == 0 { + c.warnRequiredCheckNeverReported(owner, repo, first, "no other check reports on the head") + return false, requiredCheckNeverReportedPrefix + first, nil + } + st, _, err := c.commitCIForPRSkipping(ctx, owner, repo, branch, headSHA, number, headPushedAt, expectedCheckCacheFromContext(ctx), missing) + if err != nil { + return false, st.Reason, err + } + if !st.Green { + return false, st.Reason, nil + } + // The required set is now effectively empty, so the walk skipped every + // other red check as non-required; "all reported checks green" means + // those block here. + if len(st.FailingNonRequired) > 0 { + return false, "required-check-failing:" + st.FailingNonRequired[0], nil + } + if st.InFlight > 0 { + return false, "check-pending", nil + } + c.warnRequiredCheckNeverReported(owner, repo, first, "gating on every reported check instead") + c.info("trusted-bot lane: required check never reported; every reported check green", "tier", laneTrustedBot, "repo", displayRepo, "pr", number, "sha", headSHA, "check", first, "observed", observedOther) + return true, "", nil +} + +// warnRequiredCheckNeverReported logs +// `trusted-bot lane: required check "" never reported on ` at +// most once per repo per check per requiredCheckNeverReportedWarnEvery. +func (c *Engine) warnRequiredCheckNeverReported(owner, repo, name, action string) { + if c == nil { + return + } + key := strings.ToLower(owner + "/" + repo + ":" + name) + now := c.now() + c.requiredChecksFallbackWarnedMu.Lock() + last, seen := c.requiredCheckNeverReportedWarned[key] + if seen && now.Sub(last) < requiredCheckNeverReportedWarnEvery { + c.requiredChecksFallbackWarnedMu.Unlock() + return + } + c.requiredCheckNeverReportedWarned[key] = now + c.requiredChecksFallbackWarnedMu.Unlock() + c.warn(`trusted-bot lane: required check "`+name+`" never reported on `+owner+"/"+repo, "repo", owner+"/"+repo, "check", name, "action", action, "hint", "set auto_merge.repos."+repo+".required_checks to this repo's real required checks") +} + +// selfAuthoredSweepTier names the self-authored sweep's lane for pr on its +// log lines: "trusted-bot" for an operator-enabled bot login, "self-authored" +// for the App's own PRs, "" when neither (the prefilter then skips it). +func (c *Engine) selfAuthoredSweepTier(pr *gh.PullRequest) string { + if c == nil || pr == nil { + return "" + } + lane, ok := c.sweepLaneForAuthor(hgithub.SafeGetLogin(pr.GetUser())) + if !ok { + return "" + } + return lane +} diff --git a/src/pkg/github/automerge/automerge_trusted_bot_lane_test.go b/src/pkg/github/automerge/automerge_trusted_bot_lane_test.go new file mode 100644 index 0000000000..270c16ccc3 --- /dev/null +++ b/src/pkg/github/automerge/automerge_trusted_bot_lane_test.go @@ -0,0 +1,315 @@ +package automerge + +// The trusted-bot lane must honor every bot login the operator enabled in +// Settings (auto_merge.trusted_bot_authors): claim the PR itself, never +// bounce it to the contributor lane as app-authored, treat the review +// swarm's verdict as advisory while trusted_bot_skip_review is on, and name +// an absent configured required check instead of parking the PR at a bare +// "needs a person". + +import ( + "bytes" + "context" + "encoding/json" + "log/slog" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" + + gh "github.com/google/go-github/v72/github" + + "github.com/hivecommons/hive/pkg/config" + hgithub "github.com/hivecommons/hive/pkg/github" + "github.com/hivecommons/hive/pkg/stageengine/prstage" +) + +// TestTrustedBotLaneClaimsEveryConfiguredBot iterates every Settings toggle +// (config.KnownBotAuthors) plus a custom login the operator typed in: each +// is owned by the trusted-bot lane and handed off by the contributor lane +// under its own reason, never contributor-lane:app-authored. +func TestTrustedBotLaneClaimsEveryConfiguredBot(t *testing.T) { + custom := "KubeStellar-Console[bot]" + configured := append(append([]string{}, config.KnownBotAuthors...), custom) + am := config.AutoMergeConfig{TrustedBotAuthors: configured} + c := newTrustedBotEngine(t, am.TrustedBotAuthorSet) + for _, login := range configured { + for _, spelled := range []string{login, strings.ToUpper(login)} { + lane, ok := c.sweepLaneForAuthor(spelled) + if !ok || lane != laneTrustedBot { + t.Errorf("sweepLaneForAuthor(%q) = (%q, %v), want (%q, true)", spelled, lane, ok, laneTrustedBot) + } + pr := selfAuthoredListPR(func(pr *gh.PullRequest) { pr.User = &gh.User{Login: gh.Ptr(spelled)} }) + if got := c.prefilterSelfAuthoredPR(pr); got != "" { + t.Errorf("prefilterSelfAuthoredPR(%q) = %q, want admitted", spelled, got) + } + if got := c.prefilterContributorLanePR(pr, ContributorLanePolicy{Enabled: true}); got != trustedBotLaneSkipReason { + t.Errorf("prefilterContributorLanePR(%q) = %q, want %q", spelled, got, trustedBotLaneSkipReason) + } + if got := c.selfAuthoredSweepTier(pr); got != laneTrustedBot { + t.Errorf("selfAuthoredSweepTier(%q) = %q, want %q", spelled, got, laneTrustedBot) + } + } + } + // The App's own PR keeps the historical contributor-lane hand-off reason. + appPR := selfAuthoredListPR(nil) + if got := c.prefilterContributorLanePR(appPR, ContributorLanePolicy{Enabled: true}); got != contributorLaneReasonAppAuthored { + t.Errorf("App PR contributor-lane prefilter = %q, want %q", got, contributorLaneReasonAppAuthored) + } + // A bot the operator did not enable is nobody's: not the trusted-bot lane's. + if lane, ok := c.sweepLaneForAuthor("mergify[bot]"); ok { + t.Errorf("unconfigured bot admitted to lane %q", lane) + } +} + +// The Settings toggles are read through the live config on every call: a +// reload that adds or removes a login takes effect without a restart. +func TestTrustedBotLaneReadsLiveConfig(t *testing.T) { + cfg := &config.Config{} + c := newTrustedBotEngine(t, func() map[string]bool { return cfg.AutoMerge.TrustedBotAuthorSet() }) + if lane, ok := c.sweepLaneForAuthor("renovate[bot]"); ok { + t.Fatalf("renovate admitted before being enabled: lane %q", lane) + } + cfg.AutoMerge.TrustedBotAuthors = []string{"dependabot[bot]", "renovate[bot]"} + if lane, ok := c.sweepLaneForAuthor("renovate[bot]"); !ok || lane != laneTrustedBot { + t.Fatalf("renovate not admitted after enabling: (%q, %v)", lane, ok) + } + cfg.AutoMerge.TrustedBotAuthors = []string{} + if _, ok := c.sweepLaneForAuthor("dependabot[bot]"); ok { + t.Fatal("explicit empty list must disable the lane") + } +} + +func TestTrustedBotSkipsReviewDefault(t *testing.T) { + if !(config.AutoMergeConfig{}).TrustedBotSkipsReview() { + t.Fatal("trusted_bot_skip_review must default to true") + } + off := false + if (config.AutoMergeConfig{TrustedBotSkipReview: &off}).TrustedBotSkipsReview() { + t.Fatal("trusted_bot_skip_review: false must be honored") + } +} + +// TestTrustedBotLaneVerdictAdvisory: a requires_human / decision-requested / +// changes_requested swarm verdict on a trusted bot's PR is advisory, so it +// neither routes to 085 nor blocks; the self-authored lane and an operator +// who turned the knob off keep the verdict as-is. +func TestTrustedBotLaneVerdictAdvisory(t *testing.T) { + requiresHuman := ContributorLaneVerdict{Configured: true, Verdict: "requires_human", DecisionQuestion: "major bump of yaml action; is this wanted?"} + decision := ContributorLaneVerdict{Configured: true, Verdict: "approve", DecisionRequested: true, DecisionFinding: "risk-class"} + changes := ContributorLaneVerdict{Configured: true, Verdict: "changes_requested"} + approved := ContributorLaneVerdict{Configured: true, Verdict: "approve", Approved: true} + answered := ContributorLaneVerdict{Configured: true, Verdict: "requires_human", DecisionAnswered: true, DecisionAnsweredBy: "alice"} + + var logs bytes.Buffer + c := newTrustedBotEngine(t, func() map[string]bool { return map[string]bool{"dependabot[bot]": true} }) + c.logger = slog.New(slog.NewJSONHandler(&logs, nil)) + + for _, tc := range []struct { + name string + lane string + skip func() bool + in ContributorLaneVerdict + advisory bool + }{ + {name: "requires_human on trusted-bot", lane: laneTrustedBot, in: requiresHuman, advisory: true}, + {name: "decision requested on trusted-bot", lane: laneTrustedBot, in: decision, advisory: true}, + {name: "changes_requested on trusted-bot", lane: laneTrustedBot, in: changes, advisory: true}, + {name: "nil knob defaults on", lane: laneTrustedBot, skip: nil, in: requiresHuman, advisory: true}, + {name: "approved stays approved", lane: laneTrustedBot, in: approved}, + {name: "answered verdict left alone", lane: laneTrustedBot, in: answered}, + {name: "knob off keeps the hold", lane: laneTrustedBot, skip: func() bool { return false }, in: requiresHuman}, + {name: "self-authored lane unaffected", lane: "self-authored", in: requiresHuman}, + } { + t.Run(tc.name, func(t *testing.T) { + c.trustedBotSkipReview = tc.skip + if tc.skip == nil && tc.name != "nil knob defaults on" { + c.trustedBotSkipReview = func() bool { return true } + } + logs.Reset() + got := c.trustedBotLaneVerdict("acme/widget", 7, "sha7", tc.lane, tc.in) + d := stageDetail{Verdict: got, VerdictKnown: true} + if tc.advisory { + if verdictNeedsHuman(d) || verdictBlocks(d) || got.Verdict != trustedBotAdvisoryVerdict || got.DecisionRequested { + t.Fatalf("verdict not advisory: %+v", got) + } + if !strings.Contains(logs.String(), "review verdict advisory") || !strings.Contains(logs.String(), `"tier":"trusted-bot"`) { + t.Fatalf("downgrade not logged with tier: %s", logs.String()) + } + return + } + if got.Verdict != tc.in.Verdict || got.DecisionRequested != tc.in.DecisionRequested || got.Approved != tc.in.Approved { + t.Fatalf("verdict changed: got %+v want %+v", got, tc.in) + } + if logs.Len() != 0 { + t.Fatalf("unexpected log: %s", logs.String()) + } + }) + } +} + +// TestTrustedBotLaneReviewGateAdvisory drives the whole self-authored path +// for a dependabot PR under an enforcing review gate whose swarm verdict is +// requires_human (the live kubestellar/docs#7562 shape): the PR merges, the +// evaluation is recorded unenforced, and the stage tracker never holds a +// requires_human verdict. With trusted_bot_skip_review off the gate holds. +func TestTrustedBotLaneReviewGateAdvisory(t *testing.T) { + for _, tc := range []struct { + name string + skip bool + wantHold bool + }{ + {name: "skip review (default)", skip: true}, + {name: "skip review off", skip: false, wantHold: true}, + } { + t.Run(tc.name, func(t *testing.T) { + merges := 0 + fx := selfSweepFixture{author: "dependabot[bot]", mergeApplied: true, mergeCalls: &merges} + api := newSelfSweepGuardAPI(t, fx) + defer api.Close() + var rec reviewGateRecords + c := newReviewGateSweepClient(api.URL, ReviewGate{ + Mode: func() string { return ReviewGateModeEnforce }, + Verdict: func(string, int, string) ReviewGateVerdict { return reviewGateRequiresHuman }, + }, &rec) + c.trustedBotAuthors = func() map[string]bool { return map[string]bool{"dependabot[bot]": true} } + skip := tc.skip + c.trustedBotSkipReview = func() bool { return skip } + c.stageTracker = NewStageTracker() + c.stageLabelPolicy = func() StageLabelPolicy { return StageLabelPolicy{Enabled: true} } + c.contributorLaneVerdict = func(string, int, string) ContributorLaneVerdict { + return ContributorLaneVerdict{Configured: true, Verdict: "requires_human", DecisionQuestion: "major bump"} + } + _, reason, err := c.trySweepSelfAuthoredPR(context.Background(), "acme/widget", "acme", "widget", 7, true) + if err != nil { + t.Fatalf("trySweepSelfAuthoredPR error: %v", err) + } + noted := c.stageTracker.details[stageKey("acme", "widget", 7)] + if tc.wantHold { + if reason != autoMergeReasonReviewGatePrefix+ReviewGateOutcomeRequiresHuman || merges != 0 { + t.Fatalf("reason = %q merges = %d; want review-gate hold", reason, merges) + } + if !verdictNeedsHuman(noted) { + t.Fatalf("stage verdict should still need a human when the knob is off: %+v", noted.Verdict) + } + return + } + if reason != "" || merges != 1 { + t.Fatalf("reason = %q merges = %d; want merge", reason, merges) + } + if verdictNeedsHuman(noted) { + t.Fatalf("stage tracker holds a requires_human verdict for a trusted bot: %+v", noted.Verdict) + } + if len(rec.evals) != 1 || rec.evals[0].Lane != laneTrustedBot || rec.evals[0].Enforced || rec.evals[0].Outcome != ReviewGateOutcomeRequiresHuman { + t.Fatalf("evaluations = %+v; want one unenforced trusted-bot evaluation recording requires-human", rec.evals) + } + }) + } +} + +// TestRecheckRequiredCheckNeverReported: auto_merge.required_checks names +// "build-gate" but this repo never produces it. With other checks reporting +// green the head is gated on those; with one red it blocks on that check; +// with nothing else reporting the hold names the absent check. Only the +// config-sourced required set qualifies, and only on the trusted-bot lane. +func TestRecheckRequiredCheckNeverReported(t *testing.T) { + type check struct{ name, status, conclusion string } + for _, tc := range []struct { + name string + author string + fromConfig bool + observed []check + wantGreen bool + wantReason string + }{ + {name: "other checks green", author: "dependabot[bot]", fromConfig: true, observed: []check{{"verify", "completed", "success"}, {"dco", "completed", "success"}}, wantGreen: true}, + {name: "another check red", author: "dependabot[bot]", fromConfig: true, observed: []check{{"verify", "completed", "failure"}}, wantReason: "required-check-failing:verify"}, + {name: "another check pending", author: "dependabot[bot]", fromConfig: true, observed: []check{{"verify", "in_progress", ""}}, wantReason: "check-pending"}, + {name: "nothing else reports", author: "dependabot[bot]", fromConfig: true, wantReason: requiredCheckNeverReportedPrefix + "build-gate"}, + {name: "protection-sourced set is not second-guessed", author: "dependabot[bot]", observed: []check{{"verify", "completed", "success"}}, wantReason: "required-check-missing:build-gate"}, + {name: "self-authored lane keeps waiting", author: testHiveAppBotLogin, fromConfig: true, observed: []check{{"verify", "completed", "success"}}, wantReason: "required-check-missing:build-gate"}, + } { + t.Run(tc.name, func(t *testing.T) { + api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch { + case r.Method == http.MethodGet && r.URL.Path == "/repos/acme/widget/branches/main/protection/required_status_checks": + http.Error(w, "forbidden", http.StatusForbidden) + case r.Method == http.MethodGet && r.URL.Path == "/repos/acme/widget/branches/main": + http.Error(w, "forbidden", http.StatusForbidden) + case r.Method == http.MethodGet && r.URL.Path == "/repos/acme/widget/rules/branches/main": + json.NewEncoder(w).Encode([]any{}) + case r.Method == http.MethodGet && r.URL.Path == "/repos/acme/widget/commits/sha/status": + json.NewEncoder(w).Encode(map[string]any{"state": "success", "total_count": 0}) + case r.Method == http.MethodGet && r.URL.Path == "/repos/acme/widget/commits/sha/check-runs": + runs := []map[string]string{} + for _, c := range tc.observed { + runs = append(runs, map[string]string{"name": c.name, "status": c.status, "conclusion": c.conclusion}) + } + json.NewEncoder(w).Encode(map[string]any{"total_count": len(runs), "check_runs": runs}) + default: + t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path) + } + })) + defer api.Close() + var logs bytes.Buffer + c := newAutoMergeSweepClient(api.URL) + c.logger = slog.New(slog.NewJSONHandler(&logs, nil)) + c.trustedBotAuthors = func() map[string]bool { return map[string]bool{"dependabot[bot]": true} } + c.SetRequiredChecks(map[string]bool{"build-gate": true}) + observed := map[string]bool{} + for _, o := range tc.observed { + observed[o.name] = true + } + ci := hgithub.CommitCIState{RequiredFromConfig: tc.fromConfig, MissingRequired: []string{"build-gate"}, Observed: observed, Reason: "required-check-missing:build-gate"} + pr := &gh.PullRequest{User: &gh.User{Login: gh.Ptr(tc.author)}} + green, reason, err := c.recheckRequiredCheckNeverReported(context.Background(), "acme/widget", "acme", "widget", "main", pr, 7, "sha", time.Time{}, ci, ci.Reason) + if err != nil { + t.Fatalf("recheck error: %v", err) + } + if green != tc.wantGreen || reason != tc.wantReason { + t.Fatalf("recheck = (%v, %q), want (%v, %q)", green, reason, tc.wantGreen, tc.wantReason) + } + warned := strings.Contains(logs.String(), `required check \"build-gate\" never reported on acme/widget`) + if wantWarn := tc.wantGreen || strings.HasPrefix(tc.wantReason, requiredCheckNeverReportedPrefix); warned != wantWarn { + t.Fatalf("operator warning logged = %v, want %v: %s", warned, wantWarn, logs.String()) + } + }) + } +} + +// The never-reported warning is one line per repo per check per hour. +func TestWarnRequiredCheckNeverReportedOncePerHour(t *testing.T) { + var logs bytes.Buffer + c := newAutoMergeSweepClient("http://127.0.0.1:0") + c.logger = slog.New(slog.NewJSONHandler(&logs, nil)) + now := time.Date(2026, 11, 12, 9, 0, 0, 0, time.UTC) + c.now = func() time.Time { return now } + count := func() int { return strings.Count(logs.String(), "never reported on acme/widget") } + c.warnRequiredCheckNeverReported("acme", "widget", "build-gate", "x") + c.warnRequiredCheckNeverReported("acme", "widget", "build-gate", "x") + if count() != 1 { + t.Fatalf("warned %d times within the hour, want 1", count()) + } + c.warnRequiredCheckNeverReported("acme", "widget", "other", "x") + if count() != 2 { + t.Fatalf("a different check must warn on its own: %d", count()) + } + now = now.Add(requiredCheckNeverReportedWarnEvery) + c.warnRequiredCheckNeverReported("acme", "widget", "build-gate", "x") + if count() != 3 { + t.Fatalf("after an hour the warning must repeat: %d", count()) + } +} + +// The reason is a terminal hold (logged as "automerge hold", not re-polled +// as a skip) and the stage engine derives a named human gate from it. +func TestRequiredCheckNeverReportedIsTerminalHumanGate(t *testing.T) { + reason := requiredCheckNeverReportedPrefix + "build-gate" + if !isTerminalRequiredCheckHold(reason) { + t.Fatal("required-check-never-reported must be a terminal hold") + } + if prstage.RequiredCheckNeverReportedPrefix != requiredCheckNeverReportedPrefix { + t.Fatal("prefix drifted from prstage") + } +} diff --git a/src/pkg/github/commit_ci.go b/src/pkg/github/commit_ci.go index 9bd3255a93..af7ec80889 100644 --- a/src/pkg/github/commit_ci.go +++ b/src/pkg/github/commit_ci.go @@ -95,6 +95,11 @@ type CommitCIState struct { // the required-check set is unknown or empty and server-side enforcement is // authoritative. IgnoredMetaContexts []string + // RequiredFromConfig is true when the required set the walk gated on came + // from auto_merge.required_checks rather than the branch's protection + // (CommitCIOptions.RequiredKnownFromConfig), so a MissingRequired name + // may simply not exist on this repo. + RequiredFromConfig bool // MissingRequired lists the config/protection-declared required check // names (when that set is known) for which NO status and NO check run // exists on the SHA. A required check that has not been created yet is @@ -444,6 +449,7 @@ func HeadCommitPushedAt(ctx context.Context, client *gh.Client, owner, repo, sha // ("status-check" or "check-runs"). func EvaluateCommitCI(ctx context.Context, client *gh.Client, owner, repo, sha string, opts CommitCIOptions) (CommitCIState, error) { var st CommitCIState + st.RequiredFromConfig = opts.RequiredKnownFromConfig if client == nil { st.Reason = "status-check" return st, ErrNoGitHubClient diff --git a/src/pkg/stageengine/derive_pr_classify.go b/src/pkg/stageengine/derive_pr_classify.go index 3981925e48..2ef71863b0 100644 --- a/src/pkg/stageengine/derive_pr_classify.go +++ b/src/pkg/stageengine/derive_pr_classify.go @@ -66,6 +66,7 @@ const ( stageReasonSharedCIIncident = prstage.StageReasonSharedCIIncident trustedBotLaneSkipReason = prstage.TrustedBotLaneSkipReason workflowApprovalRequiredPrefix = prstage.WorkflowApprovalRequiredPrefix + requiredCheckNeverReportedPrefix = prstage.RequiredCheckNeverReportedPrefix stageReasonUnauthorizedPrefix = prstage.StageReasonUnauthorizedPrefix ) @@ -449,6 +450,12 @@ func ClassifyStage(o stageObservation) stageVerdict { if strings.HasPrefix(reason, workflowApprovalRequiredPrefix) { return stageVerdict{Stage: stagelabels.NeedsDecision, Rank: stageRankOwned, Human: true} } + if strings.HasPrefix(reason, requiredCheckNeverReportedPrefix) { + // The configured required check does not exist on this repo and no + // other check vouches for the head: the human gate names the check + // instead of a bare "needs a person". + return stageVerdict{Stage: stagelabels.NeedsDecision, Rank: stageRankOwned, Human: true} + } if strings.HasPrefix(reason, stageReasonUnauthorizedPrefix) { // The App lacks the permission the next step needs; only a person // can take it (hivecommons/hive#14589). The reason keeps the step. diff --git a/src/pkg/stageengine/prstage/reasons.go b/src/pkg/stageengine/prstage/reasons.go index 7c24a58b9a..13854d3a2b 100644 --- a/src/pkg/stageengine/prstage/reasons.go +++ b/src/pkg/stageengine/prstage/reasons.go @@ -82,6 +82,11 @@ const ( TrustedAuthorReasonAppAuthored = "trusted-author:app-authored" TrustedBotLaneSkipReason = "trusted-bot-lane" WorkflowApprovalRequiredPrefix = "workflow-approval-required:" + // RequiredCheckNeverReportedPrefix: auto_merge.required_checks names a + // check that has never reported on this repo, so the trusted-bot lane + // cannot gate on it and no other check vouches for the head. A person + // (or a per-repo required_checks override) resolves it. + RequiredCheckNeverReportedPrefix = "required-check-never-reported:" ) // HumanMergeReason codes: why a PR parked at 090 ready-for-human-merge From 462a31fae77a991ed4a2a3dcaddc322771bef28d Mon Sep 17 00:00:00 2001 From: hive-release-bot Date: Tue, 10 Nov 2026 19:59:47 +0000 Subject: [PATCH 07/69] =?UTF-8?q?=F0=9F=94=96=20release:=20v5.211.21?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated release commit. Compiles changelog.d/ fragments and moves the CHANGELOG.md Unreleased section into a dated v5.211.21 entry. See src/docs/releases.md. Signed-off-by: hive-release-bot --- CHANGELOG.md | 6 ++++++ changelog.d/fixed-trusted-bot-lane-dependabot.md | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 changelog.d/fixed-trusted-bot-lane-dependabot.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fbf7e8b15..a1243d8762 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ Hive did not historically maintain a complete changelog. This file starts a prag ## Unreleased +## 2026-11-10 (v5.211.21) + +### Fixed + +- Trusted-bot automerge lane: PRs from every login the operator enabled under `auto_merge.trusted_bot_authors` (Settings bot toggles or a custom login) are now honored by the trusted-bot lane end to end. The review swarm's verdict is advisory for them by default (`auto_merge.trusted_bot_skip_review`, default `true`), so a Dependabot bump a reviewer routed to `requires_human` no longer parks at "needs a person" while its checks are green; the contributor lane hands bot PRs off as `trusted-bot-lane` instead of `contributor-lane:app-authored`; every self-authored-sweep skip/hold line carries `tier`; and when `auto_merge.required_checks` names a check a repo never runs, the lane gates on the checks that do report (warning once per repo per hour) or holds with `required-check-never-reported:`, which the Activity Monitor shows as the human-gate reason (#17577). + ## 2026-11-10 (v5.211.20) ### Changed diff --git a/changelog.d/fixed-trusted-bot-lane-dependabot.md b/changelog.d/fixed-trusted-bot-lane-dependabot.md deleted file mode 100644 index b2d645de1c..0000000000 --- a/changelog.d/fixed-trusted-bot-lane-dependabot.md +++ /dev/null @@ -1 +0,0 @@ -- Trusted-bot automerge lane: PRs from every login the operator enabled under `auto_merge.trusted_bot_authors` (Settings bot toggles or a custom login) are now honored by the trusted-bot lane end to end. The review swarm's verdict is advisory for them by default (`auto_merge.trusted_bot_skip_review`, default `true`), so a Dependabot bump a reviewer routed to `requires_human` no longer parks at "needs a person" while its checks are green; the contributor lane hands bot PRs off as `trusted-bot-lane` instead of `contributor-lane:app-authored`; every self-authored-sweep skip/hold line carries `tier`; and when `auto_merge.required_checks` names a check a repo never runs, the lane gates on the checks that do report (warning once per repo per hour) or holds with `required-check-never-reported:`, which the Activity Monitor shows as the human-gate reason (#17577). From b218cb2e244a87b23ef5bc15cb0f1459a0016f91 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:10:13 +0000 Subject: [PATCH 08/69] =?UTF-8?q?=F0=9F=90=9B=20fix:=20memoise=20repos=20t?= =?UTF-8?q?he=20GitHub=20App=20cannot=20write=20labels=20in=20so=20stage-l?= =?UTF-8?q?abel=20provisioning=20stops=20retrying=20every=20sweep=20(#1758?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- changelog.d/fixed-stage-label-403-memo.md | 1 + src/pkg/github/client.go | 4 + .../github/issue_needs_decision_migration.go | 3 + src/pkg/github/issue_stage_labels.go | 11 +- src/pkg/github/issue_stage_labels_test.go | 101 ++++++++++++++++++ 5 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 changelog.d/fixed-stage-label-403-memo.md diff --git a/changelog.d/fixed-stage-label-403-memo.md b/changelog.d/fixed-stage-label-403-memo.md new file mode 100644 index 0000000000..7cc560fc1a --- /dev/null +++ b/changelog.d/fixed-stage-label-403-memo.md @@ -0,0 +1 @@ +- Issue stage labels: a repository where the GitHub App is refused label writes (403 "Resource not accessible by integration", e.g. the App lacks Issues write access) is now skipped until restart after one clear warning, instead of retrying label provisioning for every issue on every sweep and flooding the log with "provisioning failed" (#17582). diff --git a/src/pkg/github/client.go b/src/pkg/github/client.go index ffd41523b6..a80e5a2557 100644 --- a/src/pkg/github/client.go +++ b/src/pkg/github/client.go @@ -451,6 +451,10 @@ type Client struct { // stageArchived memoises repos GitHub refused label writes on because // they are archived (hivecommons/hive#14026); the sweep skips them. stageArchived coveredByPRLabelState + // stageLabelForbidden memoises repos where the GitHub App was refused + // label writes with 403 "Resource not accessible by integration" + // (hivecommons/hive#17582); the sweep skips them until restart. + stageLabelForbidden coveredByPRLabelState // legacyDecisionLabels memoises repos whose retired needs-decision / // needs-direction definitions were deleted (hivecommons/hive#12683), or // whose definition cleanup was denied integration permission (#14372). diff --git a/src/pkg/github/issue_needs_decision_migration.go b/src/pkg/github/issue_needs_decision_migration.go index b9d8b29c9a..f433ae7024 100644 --- a/src/pkg/github/issue_needs_decision_migration.go +++ b/src/pkg/github/issue_needs_decision_migration.go @@ -118,6 +118,9 @@ func (c *Client) MigrateIssueNeedsDecisionStage(ctx context.Context, opts IssueN continue } owner, name := c.splitRepo(item.Repo) + if repoKey := strings.ToLower(owner + "/" + name); c.stageArchived.has(repoKey) || c.stageLabelForbidden.has(repoKey) { + continue + } if err := c.ensureStageLabelFamily(ctx, item.Repo); err != nil { report.Errors = append(report.Errors, fmt.Sprintf("%s#%d: provisioning stage labels: %v", item.Repo, item.Number, err)) continue diff --git a/src/pkg/github/issue_stage_labels.go b/src/pkg/github/issue_stage_labels.go index b36c113be9..8f8a162abc 100644 --- a/src/pkg/github/issue_stage_labels.go +++ b/src/pkg/github/issue_stage_labels.go @@ -565,7 +565,7 @@ func SyncIssueStageLabelsWith(ctx context.Context, client *Client, result *Actio } continue } - if client.stageArchived.has(strings.ToLower(owner + "/" + name)) { + if repoKey := strings.ToLower(owner + "/" + name); client.stageArchived.has(repoKey) || client.stageLabelForbidden.has(repoKey) { continue } if err := client.ensureStageLabelFamily(ctx, in.Repo); err != nil { @@ -575,6 +575,8 @@ func SyncIssueStageLabelsWith(ctx context.Context, client *Client, result *Actio if logger != nil { if client.stageArchived.has(strings.ToLower(owner + "/" + name)) { logger.Warn("issue stage labels: repository is archived and read-only, skipping it until restart; remove it from the configured repos", "repo", in.Repo, "error", err) + } else if client.stageLabelForbidden.has(strings.ToLower(owner + "/" + name)) { + logger.Warn("issue stage labels: GitHub App cannot write labels in this repository, skipping it until restart; grant the App Issues write access or remove the repo from the configured repos", "repo", in.Repo, "error", err) } else { logger.Warn("issue stage labels: provisioning failed", "repo", in.Repo, "error", err) } @@ -890,7 +892,12 @@ func (c *Client) ensureStageLabelFamily(ctx context.Context, repo string) error // create or edit because the repository is archived and read-only // (hivecommons/hive#14026), so later sweeps skip it instead of retrying. func (c *Client) noteArchivedLabelRefusal(key string, err error) { - c.noteArchivedWrite(key, err) + if c.noteArchivedWrite(key, err) { + return + } + if githubStatusError(err, http.StatusForbidden) && strings.Contains(strings.ToLower(err.Error()), "resource not accessible by integration") { + c.stageLabelForbidden.mark(key) + } } // noteArchivedWrite memoises the repo when err is GitHub's 403 refusal of a diff --git a/src/pkg/github/issue_stage_labels_test.go b/src/pkg/github/issue_stage_labels_test.go index 5e2ba02b46..f5d8110a27 100644 --- a/src/pkg/github/issue_stage_labels_test.go +++ b/src/pkg/github/issue_stage_labels_test.go @@ -1354,3 +1354,104 @@ func TestNoteArchivedWrite(t *testing.T) { t.Fatal("archived repo not memoised") } } + +// hivecommons/hive#17582: a 403 "Resource not accessible by integration" on a +// label write memoises the repo as label-forbidden (not archived); a rate +// limit 403 memoises neither. +func TestEnsureStageLabelFamilyForbiddenMemo(t *testing.T) { + cases := []struct { + name string + message string + wantForbidden bool + wantArchived bool + }{ + {"integration", "Resource not accessible by integration", true, false}, + {"archived", "Repository was archived so is read-only.", false, true}, + {"rate limit", "API rate limit exceeded", false, false}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + var mu sync.Mutex + calls := 0 + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + mu.Lock() + calls++ + mu.Unlock() + if r.Method == http.MethodPost { + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"message":"` + tc.message + `"}`)) + return + } + _, _ = w.Write([]byte(`[]`)) + })) + t.Cleanup(srv.Close) + c := NewClientForTest(srv.URL, "acme", []string{"widgets"}, testLogger()) + if err := c.ensureStageLabelFamily(context.Background(), "acme/widgets"); err == nil { + t.Fatal("want the refusal surfaced") + } + if got := c.stageLabelForbidden.has("acme/widgets"); got != tc.wantForbidden { + t.Fatalf("stageLabelForbidden = %v, want %v", got, tc.wantForbidden) + } + if got := c.stageArchived.has("acme/widgets"); got != tc.wantArchived { + t.Fatalf("stageArchived = %v, want %v", got, tc.wantArchived) + } + }) + } +} + +// The sweep pays one refused create for an App without label access, logs the +// distinct warning once, and skips the repo on later sweeps. +func TestSyncIssueStageLabels_LabelForbiddenRepoSkippedOnLaterSweeps(t *testing.T) { + fake := newIssueStageServer(t) + var mu sync.Mutex + labelCalls := 0 + front := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if strings.HasSuffix(r.URL.Path, "/repos/acme/widgets/labels") { + w.Header().Set("Content-Type", "application/json") + mu.Lock() + labelCalls++ + mu.Unlock() + if r.Method == http.MethodPost { + w.WriteHeader(http.StatusForbidden) + _, _ = w.Write([]byte(`{"message":"Resource not accessible by integration"}`)) + return + } + _, _ = w.Write([]byte(`[]`)) + return + } + fake.srv.Config.Handler.ServeHTTP(w, r) + })) + t.Cleanup(front.Close) + + var logMu sync.Mutex + var logs strings.Builder + logger := slog.New(slog.NewTextHandler(lockedWriter{mu: &logMu, w: &logs}, nil)) + c := NewClientForTest(front.URL, "acme", []string{"widgets"}, logger) + c.SetIssueStageLabels(func() IssueStagePolicy { return IssueStagePolicy{Enabled: true} }) + store := stagelabels.NewStore("", stageNow) + result := &ActionableResult{} + result.Issues = IssueResultFromItems([]Issue{{Repo: "acme/widgets", Number: 1, Labels: []string{"bug"}}}) + fake.seed(result) + ResetRateLimitPacingForTest() + resetRESTAccountingForTest(t, stageNow()) + + for sweep := 1; sweep <= 2; sweep++ { + SyncIssueStageLabelsWith(context.Background(), c, result, store, stageNow(), logger, nil) + } + mu.Lock() + got := labelCalls + mu.Unlock() + if got != 2 { + t.Fatalf("label API calls across two sweeps = %d, want 2 (one list + one refused create)", got) + } + logMu.Lock() + out := logs.String() + logMu.Unlock() + if n := strings.Count(out, "GitHub App cannot write labels in this repository"); n != 1 { + t.Fatalf("forbidden warning logged %d times, want 1:\n%s", n, out) + } + if strings.Contains(out, "provisioning failed") { + t.Fatalf("forbidden repo must not log the generic provisioning failure:\n%s", out) + } +} From 97ec9c28c75c7d4b96acb3b8bdddffea6d3a11cc Mon Sep 17 00:00:00 2001 From: hive-release-bot Date: Tue, 10 Nov 2026 20:38:48 +0000 Subject: [PATCH 09/69] =?UTF-8?q?=F0=9F=94=96=20release:=20v5.211.22?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Automated release commit. Compiles changelog.d/ fragments and moves the CHANGELOG.md Unreleased section into a dated v5.211.22 entry. See src/docs/releases.md. Signed-off-by: hive-release-bot --- CHANGELOG.md | 6 ++++++ changelog.d/fixed-stage-label-403-memo.md | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 changelog.d/fixed-stage-label-403-memo.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a1243d8762..d7f6ed6931 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,12 @@ Hive did not historically maintain a complete changelog. This file starts a prag ## Unreleased +## 2026-11-10 (v5.211.22) + +### Fixed + +- Issue stage labels: a repository where the GitHub App is refused label writes (403 "Resource not accessible by integration", e.g. the App lacks Issues write access) is now skipped until restart after one clear warning, instead of retrying label provisioning for every issue on every sweep and flooding the log with "provisioning failed" (#17582). + ## 2026-11-10 (v5.211.21) ### Fixed diff --git a/changelog.d/fixed-stage-label-403-memo.md b/changelog.d/fixed-stage-label-403-memo.md deleted file mode 100644 index 7cc560fc1a..0000000000 --- a/changelog.d/fixed-stage-label-403-memo.md +++ /dev/null @@ -1 +0,0 @@ -- Issue stage labels: a repository where the GitHub App is refused label writes (403 "Resource not accessible by integration", e.g. the App lacks Issues write access) is now skipped until restart after one clear warning, instead of retrying label provisioning for every issue on every sweep and flooding the log with "provisioning failed" (#17582). From 5490fbda35e464c845b38931b58fb43bc8e68ad0 Mon Sep 17 00:00:00 2001 From: "hivecommons-hive[bot]" <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 20:48:13 +0000 Subject: [PATCH 10/69] =?UTF-8?q?=F0=9F=90=9B=20knowledge:=20inline=20requ?= =?UTF-8?q?ired-field=20errors=20on=20Add=20Git=20Source,=20Add=20Sub=20an?= =?UTF-8?q?d=20Import=20forms=20(#17589)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 🐛 knowledge: inline required-field errors on Add Git Source, Add Sub and Import forms Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> * 🐛 knowledge: test inline field-error helpers Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> * 🐛 knowledge: use --fs-xs token for .field-error (style ratchet) Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --------- Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com> --- .../fixed-knowledge-inline-field-errors.md | 1 + .../dashboard/knowledge_field_error.test.js | 119 ++++++++++++++++++ .../dashboard/static-src/css/knowledge.css | 2 + src/pkg/dashboard/static-src/js/knowledge.js | 52 +++++--- src/pkg/dashboard/static/index.html | 54 +++++--- 5 files changed, 200 insertions(+), 28 deletions(-) create mode 100644 changelog.d/fixed-knowledge-inline-field-errors.md create mode 100644 src/pkg/dashboard/knowledge_field_error.test.js diff --git a/changelog.d/fixed-knowledge-inline-field-errors.md b/changelog.d/fixed-knowledge-inline-field-errors.md new file mode 100644 index 0000000000..04efd68687 --- /dev/null +++ b/changelog.d/fixed-knowledge-inline-field-errors.md @@ -0,0 +1 @@ +- Knowledge panel: Add Git Source, Add Subscription, Import Document and Import now show required-field errors inline under the offending input (red border, focus, `role="alert"` message) instead of a transient info toast, and required inputs are marked; fixes Clone & Index appearing to do nothing with an empty name or URL (#17587, part of #17583). diff --git a/src/pkg/dashboard/knowledge_field_error.test.js b/src/pkg/dashboard/knowledge_field_error.test.js new file mode 100644 index 0000000000..64e692dbf5 --- /dev/null +++ b/src/pkg/dashboard/knowledge_field_error.test.js @@ -0,0 +1,119 @@ +// Knowledge panel inline required-field errors (hivecommons/hive#17587): +// kbFieldError marks the input invalid, focuses it and renders one +// role="alert" message right under it; kbClearFieldError / the next edit undoes it. +// Run: node --test src/pkg/dashboard/*.test.js +const test = require('node:test'); +const assert = require('node:assert'); +const fs = require('node:fs'); +const path = require('node:path'); + +const html = fs.readFileSync(path.join(__dirname, 'static', 'index.html'), 'utf8'); +const fnSrc = name => { + const start = html.indexOf('function ' + name + '('); + assert.ok(start >= 0, name + ' not found'); + let depth = 0; + for (let i = html.indexOf('{', start); i < html.length; i++) { + if (html[i] === '{') depth++; + else if (html[i] === '}' && --depth === 0) return html.slice(start, i + 1); + } + throw new Error('unbalanced ' + name); +}; + +const makeClassList = () => { + const set = new Set(); + return { add: c => set.add(c), remove: c => set.delete(c), contains: c => set.has(c) }; +}; + +// Minimal fake DOM: an input with a sibling list, attributes, listeners and focus tracking. +const makeDoc = () => { + const doc = { focused: null, toasts: [] }; + doc.createElement = tag => { + const el = { tag, className: '', textContent: '', attrs: {}, listeners: {}, parent: null, classList: makeClassList() }; + Object.defineProperty(el, 'className', { + get() { return [...(el._cls || [])].join(' '); }, + set(v) { el._cls = new Set(String(v).split(/\s+/).filter(Boolean)); el.classList = { + add: c => el._cls.add(c), remove: c => el._cls.delete(c), contains: c => el._cls.has(c) }; }, + }); + el.setAttribute = (k, v) => { el.attrs[k] = String(v); }; + el.removeAttribute = k => { delete el.attrs[k]; }; + el.addEventListener = (type, fn, opts) => { (el.listeners[type] = el.listeners[type] || []).push({ fn, once: !!(opts && opts.once) }); }; + el.fire = type => { + const ls = el.listeners[type] || []; + el.listeners[type] = ls.filter(l => !l.once); + ls.forEach(l => l.fn()); + }; + el.focus = () => { doc.focused = el; }; + el.remove = () => { if (el.parent) el.parent.siblings.splice(el.parent.siblings.indexOf(el), 1); el.parent = null; }; + Object.defineProperty(el, 'nextElementSibling', { + get() { const s = el.parent && el.parent.siblings; return s ? s[s.indexOf(el) + 1] || null : null; }, + }); + el.insertAdjacentElement = (where, node) => { + assert.strictEqual(where, 'afterend'); + const s = el.parent.siblings; + s.splice(s.indexOf(el) + 1, 0, node); + node.parent = el.parent; + return node; + }; + return el; + }; + return doc; +}; + +const setup = () => { + const doc = makeDoc(); + const toasts = []; + const h = new Function('document', 'showToast', + fnSrc('kbClearFieldError') + '\n' + fnSrc('kbFieldError') + '; return { kbClearFieldError, kbFieldError };')(doc, (m, k) => toasts.push([m, k])); + const container = { siblings: [] }; + const input = doc.createElement('input'); + input.parent = container; + container.siblings.push(input); + return { doc, h, input, container, toasts }; +}; + +test('kbFieldError marks the input, focuses it and renders one alert under it', () => { + const { doc, h, input, container } = setup(); + h.kbFieldError(input, 'URL is required'); + assert.ok(input.classList.contains('field-invalid')); + assert.strictEqual(input.attrs['aria-invalid'], 'true'); + assert.strictEqual(doc.focused, input); + assert.strictEqual(container.siblings.length, 2); + const err = input.nextElementSibling; + assert.ok(err.classList.contains('field-error')); + assert.strictEqual(err.attrs.role, 'alert'); + assert.strictEqual(err.textContent, 'URL is required'); +}); + +test('a second call replaces the message instead of duplicating it', () => { + const { h, input, container } = setup(); + h.kbFieldError(input, 'first'); + h.kbFieldError(input, 'second'); + assert.strictEqual(container.siblings.length, 2); + assert.strictEqual(input.nextElementSibling.textContent, 'second'); +}); + +test('editing the input clears the invalid state and the message', () => { + const { h, input, container } = setup(); + h.kbFieldError(input, 'Display name is required'); + input.fire('input'); + assert.ok(!input.classList.contains('field-invalid')); + assert.ok(!('aria-invalid' in input.attrs)); + assert.strictEqual(container.siblings.length, 1); +}); + +test('kbClearFieldError clears explicitly and tolerates a clean or missing input', () => { + const { h, input, container } = setup(); + h.kbFieldError(input, 'x'); + h.kbClearFieldError(input); + assert.ok(!input.classList.contains('field-invalid')); + assert.ok(!('aria-invalid' in input.attrs)); + assert.strictEqual(container.siblings.length, 1); + h.kbClearFieldError(input); + h.kbClearFieldError(null); +}); + +test('a missing input falls back to an error toast', () => { + const { h, toasts } = setup(); + h.kbFieldError(null, 'boom'); + assert.deepStrictEqual(toasts, [['boom', 'error']]); +}); diff --git a/src/pkg/dashboard/static-src/css/knowledge.css b/src/pkg/dashboard/static-src/css/knowledge.css index 5be0869058..1f129c0545 100644 --- a/src/pkg/dashboard/static-src/css/knowledge.css +++ b/src/pkg/dashboard/static-src/css/knowledge.css @@ -165,5 +165,7 @@ .kb-vault-status-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); } .kb-vault-status-label { font-size: 0.72rem; color: var(--muted); } .kb-vault-status-value { font-size: 0.78rem; font-weight: 600; color: var(--fg); } + .field-invalid { border-color: var(--red) !important; } + .field-error { color: var(--red); font-size: var(--fs-xs); margin-top: var(--sp-1); } @media (max-width: 768px) { .kb-layout { grid-template-columns: 1fr; } } diff --git a/src/pkg/dashboard/static-src/js/knowledge.js b/src/pkg/dashboard/static-src/js/knowledge.js index f663ff58b5..f4e7c6f575 100644 --- a/src/pkg/dashboard/static-src/js/knowledge.js +++ b/src/pkg/dashboard/static-src/js/knowledge.js @@ -1657,8 +1657,8 @@ -