ci: reject Claude and Codex co-authors in PR commits - #4061
Conversation
Intentional negative test for PR #4061; no code changes. Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Intentional clean follow-up commit for PR #4061; no code changes.
|
|
|
||
| AI_COAUTHOR = re.compile( | ||
| r"^[ \t]*Co-authored-by[ \t]*:[^\r\n]*" | ||
| r"(?:\bClaude\b|\bCodex\b|<[^<>\r\n]*@(?:anthropic\.com|openai\.com)>)", |
There was a problem hiding this comment.
The name-only \bClaude\b alternative treats any co-author with Claude as a first or last name as an AI co-author, regardless of the email address. A normal trailer such as Co-authored-by: Claude Smith <claude@example.com> makes the required commit check fail and blocks otherwise valid changes from merging. This must be corrected before merging.
Artifacts
- Creates a temporary Git repository, commits the stated trailer, independently checks the regex, and invokes the hook over the commit range; it reproduces the false rejection.
- Captured output from running the reproduction script in `/home/user/repo`, showing an independent regex match and `--check` exit status 1 with its exact diagnostic; it confirms the false rejection.
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## main #4061 +/- ##
==========================================
- Coverage 78.21% 78.21% -0.01%
==========================================
Files 1428 1428
Lines 135077 135077
Branches 11708 11708
==========================================
- Hits 105653 105647 -6
- Misses 26104 26110 +6
Partials 3320 3320
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Contribution path
Small CI fix; no tracking issue.
Problem
Commit 11f4958 reached main with a Claude co-author trailer. The existing check was case-sensitive and CI did not supply the commit range it needed to inspect.
Solution
Add a
No AI co-authorsjob to the existingci-completegate, which main's active ruleset already requires. Check every incoming commit for pull requests and merge groups using full Git history and the event's base/head SHAs.Reject co-author lines containing Claude, Codex, or an anthropic.com/openai.com email, regardless of capitalization. Report offending commit SHAs and ask contributors to amend them. Ordinary human co-authors and mentions of AI tools in commit prose pass; existing base-branch history is excluded.
Reuse the existing commit-check script and run its regression tests in lint CI. No new dependencies or repository settings changes.
How to Test
uv run pytest -c /dev/null --rootdir . --noconftest bin/hooks/test_filter_commit_message.py18 tests passed, covering mixed-case trailers, both tools, human co-authors, older commits, merge parents, base-history exclusion, and invalid ranges. Also verified that the exact reported commit fails. Ruff, targeted mypy, workflow YAML validation, and commit hooks passed.
AI assistance
Codex (GPT-6) implemented and locally validated this change.
Checklist