Sub topic 9
Active, evaluate and disabled enforcement
This chapter covers the enforcement field of a ruleset. It assumes you can read a ruleset as JSON, know what a bypass actor is, and have seen how a ruleset targets branches and repositories. The goal is to let you introduce a new rule to many repositories without stopping anyone's work, and to remove it again without deleting it.
What enforcement controls
Every ruleset has an enforcement value. It decides whether the rules in that ruleset are applied to the targets you selected. The targets, rules and bypass list stay the same in every mode. Only the effect on pushes and pull requests changes.
| Value | In the web UI | Effect on a push or merge | Recorded in rule insights |
|---|---|---|---|
| `active` | Active | Rules are enforced. A violating action is blocked. | Yes |
| `evaluate` | Evaluate | Rules are not enforced. Violations are only logged. | Yes |
| `disabled` | Disabled | Rules are not enforced and not evaluated. | No |
Two details are easy to miss:
- The default for a new ruleset in the web UI is Disabled. When you create one through the API you must send
enforcementyourself, because the field is required. evaluateis available for organisation rulesets only on GitHub Enterprise Cloud and Server plans. On other plans, an organisation ruleset can only beactiveordisabled. Check your plan before you design a rollout around it.
Active
In active mode, GitHub blocks any action that breaks a rule. A direct push to a protected branch is rejected, and a pull request that lacks the required review or status check cannot be merged.
Bypass actors still apply. An actor who has bypass access for a given mode can complete the action even though the rule would normally stop it. With bypass_mode set to pull_request, the actor can only do this by merging through a pull request. With always, the actor can also push directly.
Use active once you know what the ruleset will block and who it affects.
Evaluate
In evaluate mode, GitHub checks every relevant action against the rules and records the result, but it never blocks anything. Think of it as a dry run against real traffic.
This is useful because a ruleset can look correct on paper and still break workflows nobody remembered. Common examples:
- A release bot pushes tags directly, and a new tag rule would block it.
- A repository merges through a status check named differently from the one you required.
- A required workflow fails in repositories that have no
package.json, because the workflow assumes one. - A repository uses a branch naming pattern that your
includeorexcludepatterns did not anticipate.
Evaluate mode shows these problems as log entries in rule insights, and nobody's merge fails because of them.
What evaluate does not tell you
Evaluate is a good preview, but it has limits you should plan for:
- It records what would have been blocked. It does not show how people would have reacted. A rule that is correct but surprising still needs communication.
- Some rule types report less detail than others. Required workflows, for example, are shown as passing or failing in the same way as in active mode, but a workflow that has never run on a branch gives you little data until it does.
- Results depend on traffic. A repository that sees no pushes during your evaluation period tells you nothing. Run evaluation for long enough to include releases, hotfixes and scheduled automation.
Disabled
In disabled mode, the ruleset exists but does nothing. The configuration is kept, and you can turn it back on later by changing one field.
Disabled is better than deleting a ruleset in these situations:
- You are pausing a rule during an incident and plan to restore it.
- You are preparing a ruleset in advance and want it reviewed before it takes effect.
- You want to keep the history of what the rule was, because deleting removes the ruleset and its configuration.
Since a disabled ruleset produces no insights, you cannot learn anything from it. If you want data, use evaluate.
A safe rollout sequence
The modes form a sequence you can follow for any new rule. The same ruleset moves through the stages, so the JSON you reviewed is the JSON that finally takes effect.
A practical plan looks like this:
- Create the ruleset as
disabled. Have a second person review the targets and rules. - Switch to
evaluate. Leave it for at least one full release cycle, longer for repositories that release rarely. - Read the insights. For each violation, decide whether the cause is a real process gap, a misconfigured rule, or an actor that needs a bypass entry.
- Fix the cause. Adjust patterns, add narrow bypass actors, or fix the workflows involved. Return to step 2 if you changed the rules.
- Switch to
active. Announce the date beforehand. - Keep watching the insights for a while after activation, because behaviour changes once people can no longer push around the rule.
Changing enforcement through the API
Enforcement is part of the ruleset body, so you change it with an update request. The update endpoint replaces fields you send and leaves omitted fields unchanged, so a minimal body is enough. To move an organisation ruleset to evaluate:
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
/orgs/YOUR_ORG/rulesets/RULESET_ID \
-f enforcement=evaluateRULESET_ID is the numeric ID returned when you created the ruleset. You can list the IDs with gh api /orgs/YOUR_ORG/rulesets.
To go from evaluate to active, run the same command with -f enforcement=active. To pause the rule, use -f enforcement=disabled.
For a ruleset kept in version control, change the enforcement value in the JSON file and send the whole file again with --input, as you did when creating it:
gh api \
--method PUT \
-H "Accept: application/vnd.github+json" \
/orgs/YOUR_ORG/rulesets/RULESET_ID \
--input protect-default-branch.jsonThis keeps the file as the source of truth, and a pull request that changes "enforcement": "evaluate" to "enforcement": "active" becomes a reviewable record of when the rule took effect.
Enforcement and bypass together
Enforcement and bypass are separate controls, and they are easy to confuse.
- Enforcement applies to everyone and answers "is this rule on at all?"
- Bypass applies to named actors and answers "who may skip it while it is on?"
Prefer a narrow bypass over a weaker enforcement mode when only a few actors need an exception. Setting a ruleset to evaluate to let one team work removes the protection for the whole organisation. Adding that team as a bypass actor with pull_request mode leaves the rule in force for everyone else.
The reverse also holds. Do not leave a ruleset in evaluate indefinitely as a way to avoid deciding on bypass entries. A rule that is only observed does not protect anything.
Common mistakes
- Leaving a ruleset in disabled after creation. The ruleset appears in the list, so it looks like it is working. Check the status after every create.
- Assuming evaluate blocks nothing is harmless. It blocks nothing, but it also protects nothing. A branch can be force-pushed while the rule is only evaluating.
- Treating no violations as proof of safety. A quiet evaluation period may only mean low activity. Check that the period covered the kinds of change you care about.
- Deleting instead of disabling. Deleting loses the configuration. Disable when you may want it back.
- Forgetting overlapping rulesets. If another active ruleset already enforces the same rule on the same branch, setting yours to
evaluatechanges nothing for those actions, because the other ruleset still blocks them. The reverse also holds: your evaluation data will show violations that the other ruleset blocks in practice.
Summary of decision criteria
- Use
disabledto stage a configuration or pause a rule you intend to restore. - Use
evaluateto learn what a rule would do before it affects anyone, and to confirm that required workflows and status checks behave in each targeted repository. - Use
activewhen you have reviewed the evaluation results and communicated the change.
Exercise
Your organisation ruleset protect-default-branch is active. A new required workflow should be added, but you do not know whether it passes in every repository. Which enforcement steps would you follow, and why not edit the active ruleset directly?
Show answer
Create a separate ruleset that contains the workflows rule and set it to evaluate (or add the rule to a copy of the ruleset in evaluate), so existing protection in the active ruleset stays in force. Watch rule insights across a full release cycle, fix repositories where the workflow fails, then switch the new ruleset to active. Adding the rule to the active ruleset would start blocking merges in every targeted repository immediately, including those where the workflow fails.
Exercise
A single release team needs to push tags directly for one afternoon. A colleague suggests setting the tag ruleset to evaluate for the day. What is the problem, and what is a better option?
Show answer
evaluate stops enforcement for every actor and every repository the ruleset targets, not only the release team. A better option is to add the release team as a bypass actor with the narrowest bypass_mode that allows the work, then remove the entry afterwards. This keeps the rule active for everyone else.
Exercise
You create a ruleset through the API and forget to include enforcement in the body. What do you expect, and what is the equivalent default in the web UI?
Show answer
The API requires the enforcement field, so the request is rejected as invalid. In the web UI a new ruleset starts as Disabled, so it does nothing until you change it to Evaluate or Active.