From 5a326b6ca5d3cbaf1a062d05865cb0265ecd7a49 Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Tue, 21 Apr 2026 00:35:54 +0000 Subject: [PATCH 1/3] fix: treat cancelled CI runs as non-failing in require-ci-green-before-stop Cancelled workflow runs (e.g. from superseded dependabot merges) were counted as failures, blocking the Stop event on branches with clean CI. Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 3 +++ __tests__/hooks/builtin-policies.test.ts | 5 ++--- docs/built-in-policies.mdx | 2 +- src/hooks/builtin-policies.ts | 6 +++++- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7930a68..d2103c4f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased +### Fixes +- Treat cancelled CI runs as non-failing in `require-ci-green-before-stop` policy + ## 0.0.6-beta.1 — 2026-04-20 ### Features diff --git a/__tests__/hooks/builtin-policies.test.ts b/__tests__/hooks/builtin-policies.test.ts index 636cb7d6..10f03b2c 100644 --- a/__tests__/hooks/builtin-policies.test.ts +++ b/__tests__/hooks/builtin-policies.test.ts @@ -2709,14 +2709,13 @@ describe("hooks/builtin-policies", () => { expect(result.reason).toContain("still running"); }); - it("denies when CI has a cancelled conclusion (not success/skipped)", async () => { + it("allows when CI has a cancelled conclusion (superseded runs are not failures)", async () => { mockCiScenario("feat/branch", JSON.stringify([ { status: "completed", conclusion: "cancelled", name: "deploy" }, ])); const ctx = makeCtx({ eventType: "Stop", session: { cwd: "/repo" } }); const result = await policy.fn(ctx); - expect(result.decision).toBe("deny"); - expect(result.reason).toContain("failing"); + expect(result.decision).toBe("allow"); }); it("failing checks take priority over pending checks", async () => { diff --git a/docs/built-in-policies.mdx b/docs/built-in-policies.mdx index 6055465b..5ace66e3 100644 --- a/docs/built-in-policies.mdx +++ b/docs/built-in-policies.mdx @@ -544,7 +544,7 @@ pull requests. If `gh` is not installed or not authenticated, the policy fails o ### `require-ci-green-before-stop` **Event:** Stop -**Default:** Denies stopping when CI checks are failing or still running on the current branch. Checks both GitHub Actions workflow runs and third-party bot checks (e.g. CodeRabbit, SonarCloud, Codecov). Treats `skipped` conclusions as success. Returns an informational message when all checks pass. +**Default:** Denies stopping when CI checks are failing or still running on the current branch. Checks both GitHub Actions workflow runs and third-party bot checks (e.g. CodeRabbit, SonarCloud, Codecov). Treats `skipped` and `cancelled` conclusions as success. Returns an informational message when all checks pass. No parameters. diff --git a/src/hooks/builtin-policies.ts b/src/hooks/builtin-policies.ts index bdd55ee3..5654e23d 100644 --- a/src/hooks/builtin-policies.ts +++ b/src/hooks/builtin-policies.ts @@ -1229,7 +1229,11 @@ function requireCiGreenBeforeStop(ctx: PolicyContext): PolicyResult { if (allChecks.length === 0) return allow(`No CI runs found for branch "${branch}".`); const failing = allChecks.filter( - (r) => r.status === "completed" && r.conclusion !== "success" && r.conclusion !== "skipped", + (r) => + r.status === "completed" && + r.conclusion !== "success" && + r.conclusion !== "skipped" && + r.conclusion !== "cancelled", ); if (failing.length > 0) { const names = failing.map((r) => `"${r.name}"`).join(", "); From d2c60b44d3cb94caae02fd8b7d75252a474cd4c9 Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Tue, 21 Apr 2026 00:43:26 +0000 Subject: [PATCH 2/3] fix: detect bots by GraphQL __typename instead of login suffix CodeRabbit's login is "coderabbitai" (no [bot] suffix), so the review-policies convention hook missed it. Now checks __typename === "Bot" from the GraphQL API, which reliably identifies all bot accounts. Also adds missing PR number to CHANGELOG entry per repo convention. Co-Authored-By: Claude Opus 4.6 --- .failproofai/policies/review-policies.mjs | 7 ++++--- CHANGELOG.md | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.failproofai/policies/review-policies.mjs b/.failproofai/policies/review-policies.mjs index 04342353..ffb848da 100644 --- a/.failproofai/policies/review-policies.mjs +++ b/.failproofai/policies/review-policies.mjs @@ -70,7 +70,7 @@ customPolicies.add({ isResolved comments(first: 1) { nodes { - author { login } + author { login __typename } } } } @@ -93,8 +93,9 @@ customPolicies.add({ const unresolvedBotThreads = threads.filter((t) => { if (t.isResolved) return false; - const author = t.comments?.nodes?.[0]?.author?.login ?? ""; - return author.includes("[bot]"); + const node = t.comments?.nodes?.[0]; + if (!node?.author) return false; + return node.author.__typename === "Bot" || node.author.login.includes("[bot]"); }); if (unresolvedBotThreads.length > 0) { diff --git a/CHANGELOG.md b/CHANGELOG.md index d2103c4f..d24195b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ ## Unreleased ### Fixes -- Treat cancelled CI runs as non-failing in `require-ci-green-before-stop` policy +- Treat cancelled CI runs as non-failing in `require-ci-green-before-stop` policy (#128) ## 0.0.6-beta.1 — 2026-04-20 From 12ff9bb619f7922a56f142318da1ee9243fbaf44 Mon Sep 17 00:00:00 2001 From: NiveditJain Date: Tue, 21 Apr 2026 01:23:29 +0000 Subject: [PATCH 3/3] chore: stamp changelog for 0.0.6-beta.2 release Co-Authored-By: Claude Opus 4.6 --- CHANGELOG.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d24195b9..99c0e57a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,16 @@ ## Unreleased +## 0.0.6-beta.2 — 2026-04-21 + +### Features +- Add `prefer-package-manager` builtin policy to enforce allowed package managers (e.g., uv instead of pip) (#126) + ### Fixes -- Treat cancelled CI runs as non-failing in `require-ci-green-before-stop` policy (#128) +- Treat cancelled CI runs as non-failing in `require-ci-green-before-stop` policy (#129) + +### Docs +- Emphasize convention-based policies as org-wide quality standards in getting-started, custom-policies, examples, and README (#126) ## 0.0.6-beta.1 — 2026-04-20