EasyAgentsPython 3
PR Readiness Gate
Evaluate a pull-request merge policy across required checks, review states, and required build artifacts.
25m3 sample tests7 hidden tests
An agent can produce a polished diff while tests or approvals are still missing. Build a merge-readiness gate that returns the specific blockers before a pull request can satisfy the merge policy.
Implement pr_blockers(checks, reviews, artifacts, required_checks).
Requirements
checksis a list of dictionaries withnameandstatus.- Required check 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_checksare ignored, even if they failed. - If multiple checks share a name, the last entry in
checkswins (in list order). - At least one review with state
"approved"is required. Missing approval producesapproval_required. - Any review with state
"changes_requested"blocks merge and produceschanges_requested(even when an approval is also present). - Artifacts must contain
"diff"and"tests". Missing required artifacts producemissing_artifact:diffandmissing_artifact:testsrespectively. - 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.
Review entries are evaluated directly as given: any "changes_requested" entry blocks merge even if an "approved" entry is also present.
Example
One passing required check, one approval, and both required artifacts leave no blockers:
python
checks = [{"name": "test", "status": "passed"}]
reviews = [{"user": "u", "state": "approved"}]
assert pr_blockers(checks, reviews, ["diff", "tests"], ["test"]) == []Constraints
- Keep the result deterministic.
- Leave inputs untouched.
Editor