From ffdd3df86ca40c90ced4bba82b3d2b56b1678fb8 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 16:55:08 -0500 Subject: [PATCH 1/3] =?UTF-8?q?=F0=9F=90=9B=20github:=20cancelled=20check?= =?UTF-8?q?=20carries=20no=20verdict=20when=20required=20set=20is=20unknow?= =?UTF-8?q?n?= 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> --- .../fixed-merge-gate-cancelled-check.md | 1 + src/pkg/github/commit_ci.go | 11 ++++++++++- src/pkg/github/commit_ci_test.go | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 changelog.d/fixed-merge-gate-cancelled-check.md diff --git a/changelog.d/fixed-merge-gate-cancelled-check.md b/changelog.d/fixed-merge-gate-cancelled-check.md new file mode 100644 index 0000000000..f92bee96ee --- /dev/null +++ b/changelog.d/fixed-merge-gate-cancelled-check.md @@ -0,0 +1 @@ +- Merge requests: a cancelled check (for example the 20-minute advisory mutation job timing out) no longer blocks the merge gate when the base branch's required checks cannot be read; GitHub still enforces the real required checks at merge time. Failed and timed-out checks still block (hivecommons/hive#17598). diff --git a/src/pkg/github/commit_ci.go b/src/pkg/github/commit_ci.go index 0e85d08a8a..ba5e9e4047 100644 --- a/src/pkg/github/commit_ci.go +++ b/src/pkg/github/commit_ci.go @@ -474,7 +474,9 @@ func HeadCommitPushedAt(ctx context.Context, client *gh.Client, owner, repo, sha // real CI statuses/check-runs still block so the sweep does not race in-flight // CI, while known metadata contexts are ignored. Without that option, or when // RequiredKnownEmpty says the server enforces nothing, completed failures -// still block locally (the older fail-closed positive-evidence policy). +// still block locally (the older fail-closed positive-evidence policy), +// except a cancelled check run, which carries no verdict when the required +// set is unknown. // Later blockers are still walked after the first so that Evidence and // MissingRequired are complete for the caller. A non-nil error means the // evidence could not be gathered; Reason then names the failing API @@ -657,6 +659,13 @@ func EvaluateCommitCI(ctx context.Context, client *gh.Client, owner, repo, sha s requiredSuccess[name] = true } case "neutral", "skipped": + case "cancelled": + // A cancelled run (e.g. an advisory job that hit its timeout) + // carries no verdict of its own, like opaqueWorkflowRuns. With the + // required set known it is still a required failure. + if requiredKnown { + block("required-check-failing:" + name) + } default: if requiredKnown { block("required-check-failing:" + name) diff --git a/src/pkg/github/commit_ci_test.go b/src/pkg/github/commit_ci_test.go index 1ffb3e4e7c..a835b847c1 100644 --- a/src/pkg/github/commit_ci_test.go +++ b/src/pkg/github/commit_ci_test.go @@ -149,6 +149,25 @@ func TestEvaluateCommitCIFreshHeadExpectedChecks(t *testing.T) { }, want: "pending: head pushed 1m0s ago (< min_head_age)", }, + { + name: "cancelled advisory check carries no verdict when the required set is unknown", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "success"}, + {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, + }, + opts: CommitCIOptions{RequireEvidence: true}, + wantGreen: true, + }, + { + name: "failure still blocks next to a cancelled check when the required set is unknown", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "success"}, + {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, + {"name": "lint", "status": "completed", "conclusion": "failure"}, + }, + opts: CommitCIOptions{RequireEvidence: true}, + want: "check-failure", + }, { name: "failure with known-empty required set blocks locally", checks: []map[string]string{ From add21a2d664766b1bf8f2e6a6cd988d8341652f9 Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:06:41 -0500 Subject: [PATCH 2/3] =?UTF-8?q?=F0=9F=A7=AA=20github:=20exercise=20cancell?= =?UTF-8?q?ed-check=20rule=20on=20the=20merge-gate=20path?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two new cases sat in TestEvaluateCommitCIFreshHeadExpectedChecks, whose harness forces UnknownRequiredChecksServerEnforced. That path already defers every completed failure to the merge endpoint, so the cancelled case passed for the wrong reason and the failure-next-to- cancelled case could never block (CI: want check-failure, got green). Move them to a dedicated test that calls EvaluateCommitCI the way merge_ci_gate does (no server-enforced flag), where blockCompletedFailures is true and the cancelled rule actually applies. Add a timed_out sibling. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- src/pkg/github/commit_ci_test.go | 89 +++++++++++++++++++++++++------- 1 file changed, 70 insertions(+), 19 deletions(-) diff --git a/src/pkg/github/commit_ci_test.go b/src/pkg/github/commit_ci_test.go index a835b847c1..d7f79cc724 100644 --- a/src/pkg/github/commit_ci_test.go +++ b/src/pkg/github/commit_ci_test.go @@ -149,25 +149,6 @@ func TestEvaluateCommitCIFreshHeadExpectedChecks(t *testing.T) { }, want: "pending: head pushed 1m0s ago (< min_head_age)", }, - { - name: "cancelled advisory check carries no verdict when the required set is unknown", - checks: []map[string]string{ - {"name": "build", "status": "completed", "conclusion": "success"}, - {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, - }, - opts: CommitCIOptions{RequireEvidence: true}, - wantGreen: true, - }, - { - name: "failure still blocks next to a cancelled check when the required set is unknown", - checks: []map[string]string{ - {"name": "build", "status": "completed", "conclusion": "success"}, - {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, - {"name": "lint", "status": "completed", "conclusion": "failure"}, - }, - opts: CommitCIOptions{RequireEvidence: true}, - want: "check-failure", - }, { name: "failure with known-empty required set blocks locally", checks: []map[string]string{ @@ -448,6 +429,76 @@ func TestEvaluateCommitCIFailOnAnyFailedCheck(t *testing.T) { } } +// hivecommons/hive#17598: the merge-request gate calls EvaluateCommitCI +// without UnknownRequiredChecksServerEnforced, so completed failures block +// locally when the required set is unknown. A cancelled check run (an +// advisory job that hit its timeout) carries no verdict there; a real failure +// next to it still blocks. +func TestEvaluateCommitCICancelledCheckUnknownRequiredSet(t *testing.T) { + tests := []struct { + name string + checks []map[string]string + wantGreen bool + want string + }{ + { + name: "cancelled advisory check carries no verdict", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "success"}, + {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, + }, + wantGreen: true, + }, + { + name: "failure still blocks next to a cancelled check", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "success"}, + {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, + {"name": "lint", "status": "completed", "conclusion": "failure"}, + }, + want: "check-failure", + }, + { + name: "timed_out still blocks next to a cancelled check", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "success"}, + {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, + {"name": "lint", "status": "completed", "conclusion": "timed_out"}, + }, + want: "check-timed_out", + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + api := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/repos/acme/widget/commits/sha/status": + json.NewEncoder(w).Encode(map[string]any{"state": "success", "total_count": 0}) + case "/repos/acme/widget/commits/sha/check-runs": + json.NewEncoder(w).Encode(map[string]any{"total_count": len(tt.checks), "check_runs": tt.checks}) + default: + t.Fatalf("unexpected request: %s %s", r.Method, r.URL.Path) + } + })) + defer api.Close() + client := gh.NewClient(nil) + base, err := url.Parse(api.URL + "/") + if err != nil { + t.Fatalf("ParseURL: %v", err) + } + client.BaseURL = base + + st, err := EvaluateCommitCI(context.Background(), client, "acme", "widget", "sha", CommitCIOptions{RequireEvidence: true}) + if err != nil { + t.Fatalf("EvaluateCommitCI returned error: %v", err) + } + if st.Green != tt.wantGreen || st.Reason != tt.want { + t.Fatalf("EvaluateCommitCI = (%v,%q), want (%v,%q)", st.Green, st.Reason, tt.wantGreen, tt.want) + } + }) + } +} + // hivecommons/hive#12457: the required-only gate walks past red optional // checks, but reports them so the stage engine can keep the PR out of the // merge-queue stage. Meta contexts (tide) are not red checks; a red REQUIRED From e340c8c82f529c97e7ef3a5bede809fdfeedb8ef Mon Sep 17 00:00:00 2001 From: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> Date: Tue, 10 Nov 2026 17:20:09 -0500 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=90=9B=20github:=20cancelled=20check?= =?UTF-8?q?=20still=20blocks=20when=20nothing=20enforces=20required=20chec?= =?UTF-8?q?ks=20server-side?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The cancelled-check exemption relied on GitHub enforcing the real required checks at merge time. That backstop is absent when the required set is known to be empty (unprotected base, or protection without required checks): the automerge sweep passes RequiredKnownEmpty and the merge-request gate collapses the empty set into requiredKnown=false, so a cancelled test job would have let the head through with no CI verdict. Block it as check-cancelled on both paths; the merge gate signals its collapse with a dedicated NoServerBackstop option so its metadata-context handling is unchanged. Signed-off-by: scanner <280983584+hivecommons-hive[bot]@users.noreply.github.com> --- .../fixed-merge-gate-cancelled-check.md | 2 +- src/pkg/github/commit_ci.go | 19 ++++++++++-- src/pkg/github/commit_ci_test.go | 29 ++++++++++++++++++- src/pkg/github/merge_ci_gate.go | 4 ++- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/changelog.d/fixed-merge-gate-cancelled-check.md b/changelog.d/fixed-merge-gate-cancelled-check.md index f92bee96ee..2daf019016 100644 --- a/changelog.d/fixed-merge-gate-cancelled-check.md +++ b/changelog.d/fixed-merge-gate-cancelled-check.md @@ -1 +1 @@ -- Merge requests: a cancelled check (for example the 20-minute advisory mutation job timing out) no longer blocks the merge gate when the base branch's required checks cannot be read; GitHub still enforces the real required checks at merge time. Failed and timed-out checks still block (hivecommons/hive#17598). +- Merge requests: a cancelled check (for example the 20-minute advisory mutation job timing out) no longer blocks the merge gate when the base branch's required checks cannot be read; GitHub still enforces the real required checks at merge time. When the required set is known to be empty (nothing enforced server-side), a cancelled non-advisory check still blocks locally, as do failed and timed-out checks (hivecommons/hive#17598). diff --git a/src/pkg/github/commit_ci.go b/src/pkg/github/commit_ci.go index ba5e9e4047..84f89c615c 100644 --- a/src/pkg/github/commit_ci.go +++ b/src/pkg/github/commit_ci.go @@ -180,6 +180,13 @@ type CommitCIOptions struct { // must block locally even when UnknownRequiredChecksServerEnforced is set // for metadata handling. RequiredKnownEmpty bool + // NoServerBackstop says the local gate is the only gate for this head: the + // required set is known to be empty, so the merge endpoint enforces nothing. + // A cancelled non-ignorable check-run then blocks as check-cancelled instead + // of carrying no verdict. RequiredKnownEmpty implies it; callers that collapse + // a known-empty set into requiredKnown=false without RequiredKnownEmpty (to + // keep metadata contexts in play) set this one instead. + NoServerBackstop bool } func RequiredStatusCheckContexts(ctx context.Context, client *gh.Client, owner, repo, branch string, configSet map[string]bool, configKnown bool) (map[string]bool, bool) { @@ -476,7 +483,9 @@ func HeadCommitPushedAt(ctx context.Context, client *gh.Client, owner, repo, sha // RequiredKnownEmpty says the server enforces nothing, completed failures // still block locally (the older fail-closed positive-evidence policy), // except a cancelled check run, which carries no verdict when the required -// set is unknown. +// set is unknown and the server enforces it; with no server backstop +// (RequiredKnownEmpty or NoServerBackstop) a cancelled non-ignorable check +// still blocks as check-cancelled. // Later blockers are still walked after the first so that Evidence and // MissingRequired are complete for the caller. A non-nil error means the // evidence could not be gathered; Reason then names the failing API @@ -495,6 +504,9 @@ func EvaluateCommitCI(ctx context.Context, client *gh.Client, owner, repo, sha s // list: either the server will enforce it, or it is known to be empty. ignoreMetaContexts := serverEnforcedUnknown || opts.RequiredKnownEmpty blockCompletedFailures := !serverEnforcedUnknown || opts.RequiredKnownEmpty + // A cancelled run only carries no verdict when the merge endpoint still + // enforces the real required checks; with a known-empty set nothing does. + blockCancelled := opts.RequiredKnownEmpty || opts.NoServerBackstop seen := make(map[string]bool) requiredSuccess := make(map[string]bool) ignoredMeta := make(map[string]bool) @@ -662,9 +674,12 @@ func EvaluateCommitCI(ctx context.Context, client *gh.Client, owner, repo, sha s case "cancelled": // A cancelled run (e.g. an advisory job that hit its timeout) // carries no verdict of its own, like opaqueWorkflowRuns. With the - // required set known it is still a required failure. + // required set known it is still a required failure, and with no + // server backstop it blocks locally like any other failure. if requiredKnown { block("required-check-failing:" + name) + } else if blockCancelled && !isIgnorableCICheck(name) { + block("check-cancelled") } default: if requiredKnown { diff --git a/src/pkg/github/commit_ci_test.go b/src/pkg/github/commit_ci_test.go index d7f79cc724..5f4ac0e99b 100644 --- a/src/pkg/github/commit_ci_test.go +++ b/src/pkg/github/commit_ci_test.go @@ -164,6 +164,21 @@ func TestEvaluateCommitCIFreshHeadExpectedChecks(t *testing.T) { }, want: "check-failure", }, + { + name: "cancelled with known-empty required set blocks locally", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "cancelled"}, + {"name": "lint", "status": "completed", "conclusion": "success"}, + }, + opts: CommitCIOptions{ + RequiredKnownEmpty: true, + RequireEvidence: true, + MinHeadAge: 3 * time.Minute, + HeadPushedAt: now.Add(-10 * time.Minute), + Now: func() time.Time { return now }, + }, + want: "check-cancelled", + }, { name: "require evidence refuses empty actual-required repos with no statuses", opts: CommitCIOptions{ @@ -438,6 +453,7 @@ func TestEvaluateCommitCICancelledCheckUnknownRequiredSet(t *testing.T) { tests := []struct { name string checks []map[string]string + opts CommitCIOptions wantGreen bool want string }{ @@ -449,6 +465,15 @@ func TestEvaluateCommitCICancelledCheckUnknownRequiredSet(t *testing.T) { }, wantGreen: true, }, + { + name: "cancelled check blocks when nothing enforces required checks server-side", + checks: []map[string]string{ + {"name": "build", "status": "completed", "conclusion": "success"}, + {"name": "mutation", "status": "completed", "conclusion": "cancelled"}, + }, + opts: CommitCIOptions{NoServerBackstop: true}, + want: "check-cancelled", + }, { name: "failure still blocks next to a cancelled check", checks: []map[string]string{ @@ -488,7 +513,9 @@ func TestEvaluateCommitCICancelledCheckUnknownRequiredSet(t *testing.T) { } client.BaseURL = base - st, err := EvaluateCommitCI(context.Background(), client, "acme", "widget", "sha", CommitCIOptions{RequireEvidence: true}) + opts := tt.opts + opts.RequireEvidence = true + st, err := EvaluateCommitCI(context.Background(), client, "acme", "widget", "sha", opts) if err != nil { t.Fatalf("EvaluateCommitCI returned error: %v", err) } diff --git a/src/pkg/github/merge_ci_gate.go b/src/pkg/github/merge_ci_gate.go index 6fb3055e12..05316bde4b 100644 --- a/src/pkg/github/merge_ci_gate.go +++ b/src/pkg/github/merge_ci_gate.go @@ -171,7 +171,8 @@ func (c *Client) verifyMergeRequestCI(ctx context.Context, repo string, number i cfgSet, cfgKnown := c.configRequiredChecksForRepo(owner + "/" + name) required, requiredKnown, fromConfig, _, _ := RequiredStatusCheckContextsDetailedWithSource(ctx, c.client, owner, name, baseBranch, cfgSet, cfgKnown) actualRequired, actualKnown := required, requiredKnown && !fromConfig - if actualKnown && len(required) == 0 { + noServerBackstop := actualKnown && len(required) == 0 + if noServerBackstop { // GitHub reports both "branch not protected" and "protected but no // required checks" as a known empty set. For the merge-request watcher // that must not mean "ignore failing CI": absent required-check config @@ -209,6 +210,7 @@ func (c *Client) verifyMergeRequestCI(ctx context.Context, repo string, number i RequiredKnown: requiredKnown, RequiredKnownFromConfig: fromConfig, FailOnAnyFailedCheck: true, + NoServerBackstop: noServerBackstop, ExpectedChecks: expected, MinHeadAge: minHeadAge, HeadPushedAt: minHeadAgeFrom,