--- title: "ADR 0010: Repository policy evaluation and its OWNERS fallback" --- * Status: accepted * Code: [`pkg/policy/policy.go`](https://github.com/tektoncd/pipelines-as-code/blob/main/pkg/policy/policy.go) ## Context `spec.settings.policy` lets a repository owner restrict who can trigger CI, by naming provider groups (GitLab groups, GitHub teams, Bitbucket workspaces) per trigger type. It is a deny-by-default control in a system that historically relied on `OWNERS` files and comment commands. Two things make the mapping less obvious than it looks. Ops commands (`/test`, `/retest`, `/ok-to-test`) are not separate event kinds in the API, so there is no natural place to put a per-command policy. And an empty policy is ambiguous: it can mean "no restriction" or "nobody", and returning "not set" for it would silently open a repository that was meant to be locked down. ## Decision * `ok-to-test` and `retest` share one policy list. One policy governs who may retrigger CI by comment. * `pull_request`, `comment`, `pull_request_labeled` and `pull_request_closed` share the `pull_request` policy list. A comment on a pull request is the same event with a different source. * `push`, `cancel`, the check-run reraise triggers and `incoming` are outside policy control and return `ResultNotSet`. Adding one means adding a field to the policy API, not reusing an existing list. * A policy object that exists but lists no groups is a denial, with two distinct reasons: `no policy set` when the list is empty as written, and `policy set and empty with no groups` when it was non-empty but only contained empty strings. Both are reported as `ResultDisallowed`, never as `ResultNotSet`. * Policy takes precedence over `OWNERS`: a sender allowed by the policy runs without consulting `OWNERS`, and a sender denied by the policy still gets the `OWNERS` check before being refused, because repository owners keep their override. Only when both deny is the event refused. ## Consequences * A repository cannot express "these groups may comment, those may push". Everything lands on one of two lists. * Configuring an empty policy locks the repository to whoever is in `OWNERS`. That is intentional, and it is also the easiest way to break a working setup while editing YAML. * The `OWNERS` fallback means a policy never removes the repository owner's ability to trigger CI. An owner who wants a hard lock has to change `OWNERS`, not the policy.