AI agent getting started? Read Agents: start here first.
Branch rules control updates, review requirements and deletion. Use this page to look up exact settings after choosing the protection your team needs.
How to read this page
Section titled “How to read this page”The owner is the project or organisation that manages the rule. The pattern chooses branches; the extent chooses which data on those branches it protects. Defaults apply when adding a rule, not when updating one.
Branch rules
Section titled “Branch rules”main is unlocked by default. A rule belongs to one project or the organisation. It has a pattern,
an extent and settings. The pattern selects matching branches; the extent determines which data the rule controls on those branches.
| Owner and extent | What it controls | Patterns |
|---|---|---|
Project, ref | Every object and relationship on the matching project branch | <projectId>/ and a glob, such as <projectId>/release-* |
Project, rows | Only that project’s objects and relationships on the matching branch | main or the project’s own branches |
Organisation, ref | Every object and relationship on matching organisation branches | main, or a glob such as release-* or * |
An organisation cannot own a rows rule. Use a project rows rule to control that project’s objects and relationships on main; use an organisation ref rule to control the whole trunk. Rules never grant access to
another project’s data.
Patterns
Section titled “Patterns”A pattern is a glob, as on GitHub. A rule has one pattern, with no include or exclude lists.
| Form | Matches |
|---|---|
* | Any characters except / |
** | Any characters, including / |
? | One character except / |
[abc], [a-c] | One character of the set. A set cannot be negated: [^a] and [!a] are refused. |
* stops at /, so <projectId>/release-* matches release-1 and not release-1/fix. Use
<projectId>/release-** to match both. A glob is at most 255 characters.
Patterns differ from GitHub in four ways:
- Patterns match without regard to letter case, so
Release-*matchesrelease-1. - A project rule’s
<projectId>/is literal and the glob applies after it, so a pattern never reaches another project’s branches. - An organisation rule never matches a project branch, and matches
mainonly when its pattern is exactlymain.*alone matches every organisation branch and notmain. **is any characters, and no zero-directory form exists, so<projectId>/**/finalmatches<projectId>/a/finaland does not match<projectId>/final.
A rule written as <projectId>/* or <projectId>/<name>/* before patterns took this form matched
every depth under that prefix. Such a rule now reads <projectId>/** or <projectId>/<name>/**,
which matches the same branches. Nothing else about the rule changed. A pattern you add now as
<projectId>/* matches one level.
Rule settings
Section titled “Rule settings”| Setting | What you set | Default on a new rule |
|---|---|---|
Updates (consequence) | open, merge-only or locked-rows-only | merge-only |
Require a proposal (requireProposal) | Yes or no | Yes |
Required approvals (requiredApprovals) | A count from 0 to 10 | 1 |
Minimum approver role (approverMinRole) | Contributor, Maintainer, Owner or none | Maintainer |
Named approvers (approvers) | People who read the project or organisation the rule belongs to | None |
Restrict deletions (restrictDeletions) | Enable only for a project’s ref rule | On there; off elsewhere |
Bypass (bypass) | Roles, people, service identities or OAuth clients | Owner and Maintainer |
open leaves updates unrestricted by this setting. merge-only restricts updates to merges.
locked-rows-only applies that restriction to objects holding a merge-only lock. Other matching
rules, type rules and locks still apply.
A positive approval count needs a proposal requirement and at least one way to choose approvers: a minimum role, named people, or both. Setting the minimum role to none leaves only the named people. A named approver must be a member who reads the project or organisation the rule belongs to.
Bypass lists
Section titled “Bypass lists”A bypass list belongs to one rule and skips that rule’s settings for its eligible members. Several rules can match the same branch; each still applies unless you are covered by its bypass list. A bypass never supplies missing project access or overrides an immutable or owned type or a frozen lock.
A role entry names Contributor, Maintainer or Owner and applies to a person’s user token. A person entry names one person who reads the project or organisation the rule belongs to. Service and OAuth client entries name live identities in the same organisation; they do not inherit a person’s role entry. An agent run matches no bypass entry, and a hosted app cannot be named. Direct edits, merges and disposals through a person’s bypass require a web session or a CLI session in human mode; an agent-mode CLI session keeps the update restriction.
Manage a rule
Section titled “Manage a rule”To change a rule, you need administer projects permission in the project or organisation it belongs to. Listing needs read.
Use openeng rules add with an explicit extent and pattern, and openeng rules update to change
settings in place. Omitted settings take the defaults on add and keep their values on update.
A supplied approver or bypass array replaces that list; an empty array clears it. An update keeps
the rule’s identifier, pattern and extent, so there is no gap between removing and replacing a rule.
Every update from an agent-mode CLI session asks you to confirm in your browser, whether it strengthens or weakens the rule. Add, update and remove each write an audit record with the settings before and after. See Change control for commands.
Invalid owner, extent and pattern combinations answer invalid-rule-pattern. Settings that do not
fit together answer invalid-rule-setting. An unknown or unsuitable approver or bypass identity
answers unknown-rule-member, whether it is absent or belongs outside the rule’s project or organisation.
See Refusals for meanings and next steps.
An add with the same owner, case-insensitive pattern, extent and consequence returns the existing rule without
an audit write if its settings are identical; otherwise it is refused with duplicate-rule. A different
consequence can create a separate rule.
Changing a rule’s consequence to one another rule on that pattern already has is also refused
duplicate-rule.
A direct write can be rejected with protected or read-only-ref because of a branch rule. A merge
that encounters objects or relationships a rule protects, in a project you write, answers protected with the rule’s
patterns. A nonexistent name causes
nonexistent-ref; an organisation that is not ready causes organisation-not-ready.
See Refusals for meanings and next steps.
Matching rules can require proposals and approvals on merges. Without bypass, a missing proposal
from the source to the target answers proposal-required; unmet approvals for the subject project
answer approvals-required with counted and required numbers. Approvals count only at the current
source head. With no matching rule, writers of all affected projects may merge, including Contributors.
Bypass membership applies to each rule separately. A role entry admits a person’s token; it does not extend to that person’s agent or client app. Services and client apps need their own entries. Bypass lifts that rule’s proposal and approval requirements while project write permissions still apply. Agent runs and hosted apps cannot merge or dispose, even with bypass membership.
Configure branch rules
Section titled “Configure branch rules”You need administer projects on the project’s rules, or in the organisation for its rules.
Choose exactly one of --project <id> and --organisation. Listing needs read on that project or organisation.
Use these commands with the identifiers returned by your instance:
openeng rules add --project <id> --extent rows --pattern main --consequence merge-onlyopeneng rules list --project <id> --jsonopeneng rules update --project <id> --rule-id <rule-id> --required-approvals 2Name the extent when adding a rule. ref covers every object and relationship on a matching branch; rows covers only
those in the owner’s project. A project ref pattern is <projectId>/ and a glob. A project rows
rule may also name main. Organisation rules use extent ref and name main or a glob over one
organisation branch, such as release-* or *. See
Patterns for the forms.
Add and update accept every setting below. Omit a setting on add to take its default; omit it on update to keep its current value. See Rule settings for the defaults and how settings fit together.
| Flag | Value |
|---|---|
--consequence | open, merge-only or locked-rows-only |
--require-proposal | true or false |
--required-approvals | An integer from 0 to 10 |
--approver-min-role | contributor, maintainer, owner or null for named approvers only |
--restrict-deletions | true or false; true is allowed only on a project’s ref rule |
--approvers | A JSON array of person identifiers |
--bypass | A JSON array of bypass entries |
For example, name a reviewer and replace the bypass list:
openeng rules update --project <id> --rule-id <rule-id> \ --approvers '["<person-id>"]' --bypass '[{"kind":"role","roleKey":"owner"}]'Bypass entries use kind: "role" with roleKey, kind: "person" with personId,
kind: "service" with serviceIdentityId, or kind: "client" with clientId.
Each supplied array replaces the corresponding whole list; [] clears it. People must be members
who read the project or organisation, and named services and clients must be live in the organisation.
A positive approval count needs a proposal and either a minimum approver role or named approvers.
Deletion restrictions cannot be enabled on rows or organisation rules.
An update keeps the same rule identifier, extent and pattern. It changes settings and member lists in one call. Every update from an agent-mode CLI session prints a confirmation address and waits for the person to confirm in their browser, whether it raises or lowers a restriction. Add, update and remove each record the settings before and after in the audit history.
openeng rules remove --project <id> --rule-id <rule-id> removes a rule. Other matching rules still
apply. Use --organisation in place of --project <id> for organisation rules.
Configuration refusals name invalid-rule-pattern, invalid-rule-setting or unknown-rule-member.
An absent or other owner’s rule identifier answers not-found. Check the owner, extent, pattern
and supplied settings before repeating the call.
An add with the same owner, case-insensitive pattern, extent and consequence returns the existing rule without
an audit write if its settings are identical; otherwise it is refused with duplicate-rule. A different
consequence can create a separate rule.
Changing a rule’s consequence to one another rule on that pattern already has is also refused
duplicate-rule.
The Administration SDK sends the same extent, pattern and settings on add, or the rule identifier
and changed settings on update. These rule routes require a person’s user token. An OAuth client
gets HTTP 401 with unauthenticated on rule add, update, remove and list calls; neither consent nor
being named on a bypass list grants rule administration.