Add `CODEOWNERS` for dependency and CI config paths, and a `PR Gates` check requiring `compatibility impact` on new API waivers

Merged
DS
1mo ago
+448-0

This pull request was posted by codex-tui using gpt-6.1-sol on behalf of David.

Why we make these changes

Dependency and CI configuration changes need code-owner approval, and new API compatibility waivers need a release-note label. This PR adds native review enforcement and a metadata gate:

  • .github/CODEOWNERS owns every pyproject.toml and uv.lock, .github/workflows/, .github/actions/, .github/scripts/, .pre-commit-config.yaml, Makefile, and itself. The owners are the pydantic/pydantic-ai-admin and pydantic/pydantic-ai-maintain teams. Once the main ruleset requires code-owner review (steps below), a PR that changes these paths needs an approval from an owner other than its author, and GitHub dismisses it when a later push changes the diff.
  • Gate: compatibility waiver labeled fails when a PR adds a waiver to .github/api-compatibility-allowlist.json without compatibility impact, so a waived break always reaches the release notes. It runs on pull_request with a read-only token and skips on merge_group, which GitHub reports as success, so it can be made required without stalling the merge queue.

An earlier revision gated these paths on approved:<scope> labels that a workflow removed after later pushes. That removal could fail open (a failed API call, a PR over 3000 files, two quick pushes), so GitHub's own review enforcement replaces it.

New public surface

None. CI only.

Verification

  • test_pr_gates.py covers the waiver gate, API parsing, annotations, fail-closed errors, triggers and the queue skip. Targeted pytest and Pyright passed after merging main; commit hooks passed.
  • gh api 'repos/pydantic/pydantic-ai/codeowners/errors?ref=ci-review-gates' returns {"errors": []}.
After merge: repo admin steps and open rollout checks
  1. Run gh api repos/pydantic/pydantic-ai/codeowners/errors. It must return {"errors": []}.
  2. In the main ruleset, enable Require a pull request before merging with 0 required approvals, Dismiss stale pull request approvals when new commits are pushed, and Require review from Code Owners. Leave conversation resolution and Require approval of the most recent reviewable push off (open item below).
  3. Check the ruleset's bypass list. Anyone on it can merge without owner review.
  4. Confirm nothing pushes to main directly, since the rule requires a PR for every change. No workflow does; release tooling was not checked.
  5. Open two throwaway PRs. A comment-only edit to .pre-commit-config.yaml should request the owners and block until another owner approves, and a second push should dismiss that approval. A docs/-only PR should merge with no approval.
  6. Delete the retired approved:dependencies and approved:ci-config labels.
  7. Once the waiver check has run successfully, add Gate: compatibility waiver labeled to the ruleset's required status checks, with GitHub Actions as its expected source. Verify an unlabeled waiver blocks a test PR and adding compatibility impact clears it.

Merging before step 2 lets step 1 validate the file before it is enforced.

Open items

  • Require approval of the most recent reviewable push. With it off, an owner who pushes to someone else's PR can approve their own change. Whether it binds every PR at 0 required approvals is unverified; the step 5 test PR can show it.
  • Overlapping gate runs (unverified). A synchronize run that read the labels before a label removal could finish last and leave the waiver gate green. Settle this before the gate becomes required.

What changes for existing users

Nothing in the library. After step 2, a PR that touches an owned path waits for an owner's approval.

PR decisions

2026-10-22 · Protected paths

  • Decision: pyproject.toml, uv.lock, .github/workflows/, .github/actions/, .github/scripts/, .pre-commit-config.yaml, Makefile.
  • Why: maintainer decision on the gate design.

2026-10-22 · Griffe packages out of scope

  • Decision: adding the harness and clai2 to the griffe check is a separate PR.
  • Why: that change is already in flight.

2026-10-22 · Overlapping runs (unverified, rollout note)

  • Decision: the possible race is recorded under "Open items", not fixed here and not filed as an issue.
  • Why: maintainer decision. It matters only once the gate is required.

2026-10-23 · Code owners replace approval labels

  • Decision: a self-owned .github/CODEOWNERS for the paths above, owned by the admin and maintain teams, enforced by the main ruleset's code-owner review with stale approvals dismissed. The approved:<scope> labels and the workflow that removed them are retired. .github/dependabot.yml stays unowned.
  • Why: maintainer decision. Label removal ran as a workflow on each push, and four ways for it to fail open were reproduced; GitHub dismisses a stale approval as part of the push.
  • Supersedes: the label scope, the approved:<scope> standard, agents applying approval labels, and both Macroscope voiding threads.

2026-10-23 · Waiver gate on pull_request

  • Decision: Gate: compatibility waiver labeled runs on pull_request with a read-only token.
  • Why: maintainer decision. Code-owner review already covers any edit to the gate. First-time-contributor fork runs wait for approval.

2026-10-23 · Most-recent-push approval left off

  • Decision: the admin steps leave Require approval of the most recent reviewable push off and list it as an open item.
  • Why: its reach at 0 required approvals is unverified; the throwaway test PR shows it.

2026-10-23 · Pre-push reviews of the reshape

  • Decision: review 1 found five issues. Four were fixed: the AGENTS.md wording on self-approval, a note that CODEOWNERS is what keeps the gate from being edited to pass itself, opened in the trigger test, and a trimmed test fixture. The fifth, dropping the final-review catalog row, was skipped. Review 2 found nothing.
  • Why: final-review is a live repo label missing from main's catalog, so dropping the row reintroduces that drift.

2026-10-27 · Refresh from main

  • Decision: merge current main without rewriting the branch; preserve current CI Review trigger documentation.
  • Why: validate the code-owner and waiver gates against current CI before enabling repository rules.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration, release note, and exact API-check waiver.
  • PR title is fit for the release changelog.