Skip to content

fix(ci): keep Ready blocked while deterministic hygiene fails - #1329

Merged
Wibias merged 2 commits into
devfrom
fix/gate-hygiene-ready-coupling
Aug 9, 2026
Merged

fix(ci): keep Ready blocked while deterministic hygiene fails#1329
Wibias merged 2 commits into
devfrom
fix/gate-hygiene-ready-coupling

Conversation

@Wibias

@Wibias Wibias commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Re-assess deterministic hygiene inside the PR quality gate so Ready / review-ready cannot clear while hygiene still fails (seen on fix(codex): recover incomplete account deletion cleanup #1324).
  • Wake the gate on hygiene-related labels (maintainer-sponsored, exception labels, intake: hygiene-blocked) so sponsorship can lift the draft without a new push.
  • Share collectDeterministicHygieneFailures between PR hygiene and Enforce PR target branch so the two bots cannot disagree.

Test plan

  • node --test .github/scripts/pr-hygiene.test.cjs .github/scripts/enforce-pr-target.test.cjs
  • bun test tests/ci-workflows.test.ts
  • Confirm a contributor PR touching src/codex/auth-api.ts stays draft / no review-ready until maintainer-sponsored
  • After merge to dev, promote to main (pull_request_target loads from the default branch)

Summary by CodeRabbit

  • New Features

    • Added unified pull request hygiene checks for restricted changes, sponsorship, authentication, workflows, releases, and dependencies.
    • Added approved-label and maintainer-sponsorship handling for applicable hygiene gates.
    • Added clearer failure explanations and actionable guidance for blocked checks.
  • Bug Fixes

    • Improved changed-file detection, including paginated pull requests and renamed files.
    • Prevented unsponsored restricted changes from being marked ready for review.
    • Improved validation consistency by checking the pull request’s base revision and author permissions.

Stop the PR quality gate from marking review-ready when hygiene still fails (as on #1324), and re-run the gate when sponsorship or exception labels change.
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 9, 2026
@coderabbitai

coderabbitai Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b2a12507-0fb7-40e8-8995-cb9ba24ff352

📥 Commits

Reviewing files that changed from the base of the PR and between 73af78f and 13a20c3.

📒 Files selected for processing (3)
  • .github/scripts/pr-hygiene.cjs
  • .github/scripts/pr-hygiene.test.cjs
  • .github/workflows/pr-hygiene.yml

📝 Walkthrough

Walkthrough

This change unifies deterministic hygiene and sponsored-surface checks. Both PR workflows retrieve changed files and labels, apply shared failure metadata, and enforce draft and readiness behavior. Tests cover label triggers, pagination, blocked restricted changes, and maintainer sponsorship.

Changes

Hygiene gate integration

Layer / File(s) Summary
Deterministic failure collector
.github/scripts/pr-hygiene.cjs, .github/scripts/pr-hygiene.test.cjs
collectDeterministicHygieneFailures combines hygiene and sponsored-surface failures. Shared hints and gate labels are exported. Tests cover combined failures, renamed restricted paths, and push-permission exemptions.
Workflow gate enforcement
.github/workflows/pr-hygiene.yml, .github/workflows/enforce-pr-target.yml, .github/scripts/enforce-pr-target.test.cjs
The workflows use the PR base SHA, retrieve changed files and labels, invoke the shared collector, support hygiene-related label events, and report failure hints and status reasons.
Workflow harness and end-to-end validation
tests/helpers/enforce-pr-target-harness.ts, tests/ci-workflows.test.ts
The harness supports paginated pulls.listFiles fixtures. CI tests validate read sequences, label recognition, blocked unsponsored changes, and readiness after maintainer-sponsored.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant enforce-pr-target
  participant GitHubAPI
  participant HygieneCollector
  participant PullRequest
  enforce-pr-target->>GitHubAPI: Read changed files and labels
  GitHubAPI-->>enforce-pr-target: Return PR file list and labels
  enforce-pr-target->>HygieneCollector: Evaluate files, labels, and author permission
  HygieneCollector-->>enforce-pr-target: Return hygiene failures
  enforce-pr-target->>PullRequest: Update comment, status, labels, and readiness
Loading

Possibly related PRs

Suggested labels: chore

Suggested reviewers: ingwannu, lidge-jun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: blocking Ready status while deterministic hygiene checks fail.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/gate-hygiene-ready-coupling

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/scripts/pr-hygiene.cjs:
- Around line 269-272: Update assessHygiene’s assessSponsoredSurface call to
pass a deduplicated union of each changed file’s filename and previous_filename,
preserving source paths for renames. Add a regression test covering a rename
from a restricted path, such as .github/workflows/release.yml, to a
non-restricted path and verify sponsorship is still required.

In @.github/workflows/pr-hygiene.yml:
- Around line 42-47: Update the checkout step in the workflow so
pull_request_target events check out github.event.pull_request.base.sha instead
of the repository default branch. Keep the existing require of pr-hygiene.cjs
and its collectDeterministicHygieneFailures usage unchanged, ensuring the script
is loaded from the trusted PR base revision.
- Around line 110-116: The authorHasPushPermission value passed to
collectDeterministicHygieneFailures must use repository permissions instead of
pr.author_association. Call
github.rest.repos.getCollaboratorPermissionLevel(pr.user.login), treat lookup
failures as no permission, and consider only write-capable permission levels
eligible for the sponsorship exemption; obtain explicit security review for this
.github/** change.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 240abeed-37ac-4b3d-ba49-e968614e4ca9

📥 Commits

Reviewing files that changed from the base of the PR and between 3e5cd53 and 73af78f.

📒 Files selected for processing (7)
  • .github/scripts/enforce-pr-target.test.cjs
  • .github/scripts/pr-hygiene.cjs
  • .github/scripts/pr-hygiene.test.cjs
  • .github/workflows/enforce-pr-target.yml
  • .github/workflows/pr-hygiene.yml
  • tests/ci-workflows.test.ts
  • tests/helpers/enforce-pr-target-harness.ts

Comment thread .github/scripts/pr-hygiene.cjs
Comment thread .github/workflows/pr-hygiene.yml
Comment thread .github/workflows/pr-hygiene.yml
Keep rename sources in sponsored-surface checks, load hygiene scripts from the PR base SHA, and exempt sponsorship only for write-capable repository permissions.
@Wibias
Wibias merged commit ab19769 into dev Aug 9, 2026
26 checks passed
@Wibias
Wibias deleted the fix/gate-hygiene-ready-coupling branch August 9, 2026 03:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant