Skip to content

Code owners: GitHub enforces the owner's merges

coordinator merge-kind says which pull requests are the owner's to merge (plugins/workflow/skills/coordinator/autonomy.md). On its own that is a rule the coordinator follows, nothing more: the bot account has write access and could merge any of them. .github/CODEOWNERS names @<owner> as the owner of the same paths, and the ruleset for main is meant to require a code owner's review. GitHub then refuses the merge until the owner approves (#173, from the decisions in #157; the live ruleset does not require it yet).

merge-kind stays. It is the early signal on a pull request that is not ready yet, and it covers what no path rule can:

  • the needs:owner-approval and needs:owner-merge labels;
  • an ADR in the title, and a breaking change;
  • Dependabot major updates (patch and SHA bumps merge by themselves; a minor update is the agent's call after reading its changelog);
  • forks;
  • path names in another case than the one the repository uses.

Keeping the two lists in sync

scripts/ci/check-codeowners.py runs in check-plugins.sh and fails when CODEOWNERS and OWNER_PATHS in coordinator.py disagree. It checks every tracked file plus a set of probe paths, one or more per category, that need not exist yet; a path must be owned by @<owner> exactly when merge-kind names it. A new category in OWNER_PATHS needs a CODEOWNERS line and a probe. scripts/tests/check-codeowners-test.sh tests the check itself.

The owner's rules name folders, never single scripts (#618). scripts/ is split by who must review a change:

Folder Owner What lives there
scripts/ci/ yes the gates CI and pre-commit run
scripts/linux/ yes what touches the token file, the sbx secrets or root on the host: lib.sh, rotate.sh, set-token.sh, github-account.sh, service-keys.sh, sbx-token, status.sh, root-steps.sh, harden.sh, sandbox-root-packages.sh, claude-vault-setup.sh, worktree-base.sh
scripts/sandbox/ no the sandbox lifecycle: sandboxes.sh, claude-sandbox.sh, sandbox-provision.sh
scripts/tools/ no helpers without host effect: eval-plugin.sh, create-github-labels.sh, connect-repo-remote.sh
scripts/tests/ no the tests of the four folders above; scripts/windows/ keeps its tests next to its scripts

A new script goes where its effect puts it: one that reads the token file or needs root belongs in scripts/linux/, a gate in scripts/ci/. Moving a script out of an owner folder is the owner's change, since merge-kind counts a rename's old name. Tests are never the owner's: the tests of plugins/dev-env/hooks/ and plugins/dev-env/janitor/ live in plugins/dev-env/tests/; the one test under .claude/ stays with that folder.

Before #618 all of scripts/linux/ and scripts/ci/ was the owner's (#236), and nearly every routine sandbox fix needed the owner's Approve. Of the 60 pull requests merged before the change, 28 instead of 35 would have needed it with this layout.

The split is not airtight, and the owner took it knowing that:

  • sandboxes.sh reads the token file to set the sbx secrets and installs what systemd runs;
  • claude-sandbox.sh is a unit's ExecStart on the host;
  • the tests include the gates' self-tests.

The instruction files an eval's repository fixture carries as test input—CLAUDE.md, .claude/, .mcp.json and hooks/ under plugins/*/evals/…/resources/—are not the owner's (#184); CODEOWNERS ends with lines without an owner for them. A fixture's .github/, .gitignore or ADR still is.

An eval's scaffold script is the owner's: /plugins/*/evals/**/*.sh and *.ps1, outside a fixture's resources/ (#213). claude plugin eval --scaffold runs the script a case's case.yaml names as scaffold_script on the worker's machine, as its user and outside any sandbox, before the run starts; a line added next to its cp would run with the worker's tokens at the next eval run. A fixture's hooks, .mcp.json and CLAUDE.md are inert in an eval run (#213's probe), so the scaffold script is the only code a routine pull request could get a worker to run this way. Two cases no path rule can see are merge-kind's alone: a case.yaml whose change may move scaffold_script—read from the patch, it fails closed on a hunk naming the key, on YAML a line scanner cannot follow and on a rename—and a named script with another extension—check-codeowners.py reads every case.yaml and fails until such a script has its own CODEOWNERS line. Running evals only in a sandbox is a separate follow-up (#278).

GitHub matches CODEOWNERS with case, merge-kind without. CODEOWNERS lists CLAUDE.md and claude.md; other spellings are caught only by merge-kind.

The ruleset

Ruleset changes need admin rights and are the owner's step. .github/rulesets/main.json records the intended state:

  • a pull request with Require review from Code Owners, merged by squash only;
  • the validate check;
  • the Copilot review rule (copilot-review.md).

The live ruleset, main, has the file's rules for validate, deletion and force pushes. It differs in three settings, and the code owner review is the one that matters here:

Setting File Live
Require review from Code Owners on off
Allowed merge methods squash merge, squash and rebase
Copilot review of draft pull requests on off

Until the code owner review is on, CODEOWNERS enforces nothing and merge-kind is the only guard. Importing the file again, or switching the settings by hand, is the owner's step.

Who can approve. GitHub does not count an author's review, and the pull requests here are opened under the owner's account, the code owner. With the code owner review required and no bypass, the owner cannot merge their own pull requests that touch an owned path. There are two ways out:

  • The workers open pull requests as the bot account, and the owner approves as code owner.
  • The ruleset gets a bypass for the Repository admin role, for pull requests only. The owner merges with Merge without waiting for requirements (gh pr merge --admin). An agent running under the owner's account can do the same, so with the bypass the rule binds the bot account and every merge made without --admin.

To compare the live state with the file:

gh api repos/<owner>/claude/rules/branches/main --jq '.[] | "\(.type) \(.ruleset_id) \(.parameters // {})"'