← ~/pillars / deterministic-policy / ci-as-outer-gate

CI as the outer gate

GitHub rulesets, required status checks, and CODEOWNERS as the enforcement layer that does not care who, or what, authored the PR.

updated 2026-06-10 ~3 min read pattern 04/06 Deterministic Guardrails

on this page

Context. Agents now open PRs in your repositories (from Claude Code sessions, scheduled automations, or CI-resident bots), and you need a policy layer that holds regardless of which session settings, hooks, or permission modes were active when the code was written.

Forces. In-session enforcement only binds the sessions that run it: a developer with --dangerously-skip-permissions in a container, or an agent running under different settings, produces commits your hooks never saw. Meanwhile, review requirements tuned for humans can make high-volume agent PRs unmergeable, which pressures teams into bypass habits that are worse than the problem.

Resolution. Make the repository boundary the gate. GitHub rulesets apply to every push and PR uniformly; configure them so agents and humans pass through the same checks, and route the genuinely human decisions through CODEOWNERS paths rather than blanket review counts.

Why rulesets, not classic branch protection

Rulesets are the current mechanism (about rulesets), and two properties make them the right substrate for agent governance:

  • Aggregation is most-restrictive. Multiple rulesets targeting the same branch layer together (and they layer with any legacy branch protection rules), with the most restrictive outcome applying. An org-level baseline ruleset plus a stricter repo-level one compose safely.
  • Bypass is explicit and auditable. Bypass actors are enumerated per ruleset: roles, teams, and notably GitHub Apps. That lets you give a bot identity a narrow bypass (e.g. of review-count requirements) while keeping status checks non-bypassable for everyone.

Required status checks

The “require status checks to pass” rule (available rules) is the core of the gate. Decisions to make:

  • Which checks. Name the job-level checks explicitly: build + tests, format check, dependency scan, secret scan. An agent-heavy repo should bias towards checks that catch agent failure modes: formatting drift, dependency additions, and committed credentials.
  • Strict or loose. Strict mode requires the branch to be up to date with the base before merging: stronger, but on a high-throughput repo it forces rebase churn. Loose mode (checks pass, branch may be stale) is the usual compromise; pick strict for deployment-critical branches.
  • Restrict the check source. Required checks can be limited to a specific GitHub App, preventing a workflow in the PR itself from impersonating the check name with a trivially green job.

Same gate for agents and humans

The defensible position is symmetry: an agent PR earns merge by exactly the same evidence a human PR does. Asymmetry in either direction fails: laxer gates for bots are an obvious hole, while stricter gates for bots invite laundering agent work through human accounts. Concretely:

  • Required status checks: identical, no bypass actors.
  • Block force pushes and restrict merge methods: identical.
  • Review requirements: this is where the kind of reviewer matters more than the count. A blanket “one approval” rule rubber-stamps agent PRs; a CODEOWNERS rule on the paths that need judgment puts the right human on exactly the changes that need one.

CODEOWNERS as the judgment router

Rulesets can require code-owner review, and can additionally require reviewers by file path with gitignore-style patterns (available rules). For a Java/Spring service with agents holding write access, the paths that should always reach a human:

.github/CODEOWNERS
# Dependency declarations — supply-chain surface
pom.xml @org/java-platform
**/build.gradle* @org/java-platform
# Production configuration
src/main/resources/application*.yml @org/service-owners
# Infrastructure and CI definitions
terraform/ @org/platform-infra
.github/workflows/ @org/platform-infra
# The agent policy itself
.claude/ @org/platform-infra

Note the last entry: the committed .claude/settings.json carries your hooks and permission rules, so changes to it are policy changes and deserve owner review. This is the outer-gate answer to the hook trust-model problem, where anyone with repo write access can edit project hooks.

Worked example

The required-checks artifact ships the complete pair: a GitHub Actions workflow exposing four named checks (build and test, Spotless, OWASP dependency check, secret scan) on every PR to protected branches, plus the matching ruleset configuration: those four checks required with no bypass actors, PR required before merge, force pushes blocked, stale approvals dismissed on new commits, and code-owner review on the CODEOWNERS paths above. An agent PR that passes is mergeable on the same terms as anyone else’s; one that touches pom.xml waits for the platform team, however green the checks are. That asymmetry (checks gate everything, humans gate judgment) is the whole pattern.

// sources