Skip to content
EasyAgentsPython 3

PR Readiness Gate

Evaluate an explicit pull-request policy using required checks, approval states, and named proof artifacts.

25m3 sample tests7 hidden tests

Implement pr_blockers(checks, reviews, artifacts, required_checks), a for agent-created pull requests.

Requirements

  • checks is a list of dictionaries with name and status.
  • Required names must exist and have status "passed".
  • Missing checks produce missing_check:<name>.
  • Failing checks produce failing_check:<name> (any status other than "passed" counts as failing for a required check).
  • Checks whose names are not in required_checks are ignored, even if they failed.
  • If multiple checks share a name, the last entry in checks wins.
  • "Last" refers to list order, not a timestamp. The caller must order records before calling this function if recency matters.
  • At least one review with state "approved" is required. Missing approval produces approval_required.
  • Any review with state "changes_requested" blocks merge and produces changes_requested (even when an approval is also present).
  • Artifacts must contain "diff" and "tests". Missing required artifacts produce missing_artifact:diff and missing_artifact:tests respectively.
  • Return blockers sorted lexicographically.
  • Check names, artifact names, and review states use exact, case-sensitive strings. Extra artifact names and other review states are ignored.

These are the exercise's policy labels, not raw GitHub API statuses. Returning [] means the supplied records meet this policy; the function doesn't verify check commit IDs, artifact contents, reviewer eligibility, or repository protection rules. If the input contains review history, any earlier changes_requested still blocks under the stated rule. A follow-up can instead supply each reviewer's current effective state.

Example

One passing required check, one approval, and both required artifacts leave no blockers:

python
1checks = [{"name": "test", "status": "passed"}] 2reviews = [{"user": "u", "state": "approved"}] 3assert pr_blockers(checks, reviews, ["diff", "tests"], ["test"]) == []

Constraints

  • Keep the result deterministic.
  • Leave inputs untouched.

Editor