From b7bf18916681c984aa16096269c5d777d2b815e3 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Fri, 23 Oct 2026 08:32:52 -0400 Subject: [PATCH] fix: stop the authorship check from flagging people whose names contain an assistant's name --- tools/release/authorship_hook.py | 6 +++--- tools/release/check_authorship.py | 35 ++++++++++++++++++++++++------- tools/tests/test_authorship.py | 21 +++++++++++++++++++ 3 files changed, 51 insertions(+), 11 deletions(-) diff --git a/tools/release/authorship_hook.py b/tools/release/authorship_hook.py index 3129f76153..82d0842c91 100644 --- a/tools/release/authorship_hook.py +++ b/tools/release/authorship_hook.py @@ -4,7 +4,7 @@ from pathlib import Path import subprocess import sys -from check_authorship import BOT, COAUTHOR, check_revision +from check_authorship import COAUTHOR, check_revision, is_bot def main(): @@ -23,13 +23,13 @@ def main(): return 1 else: identity = subprocess.check_output(["git", "var", "GIT_AUTHOR_IDENT"], text=True) - if BOT.search(identity): + if is_bot(identity): print("Bot commit author is forbidden: " + identity.strip(), file=sys.stderr) return 1 message = Path(args[0]) original = message.read_text(encoding="utf-8") cleaned = "".join(line for line in original.splitlines(keepends=True) - if not (COAUTHOR.match(line) and BOT.search(line))) + if not (COAUTHOR.match(line) and is_bot(line))) if cleaned != original: message.write_text(cleaned, encoding="utf-8") print("Removed bot co-author trailers; human credits preserved.", file=sys.stderr) diff --git a/tools/release/check_authorship.py b/tools/release/check_authorship.py index 9d952acc0d..37e2a716a4 100644 --- a/tools/release/check_authorship.py +++ b/tools/release/check_authorship.py @@ -6,15 +6,34 @@ import re import subprocess import sys -BOT = re.compile( - r"Claude|Anthropic|OpenAI|ChatGPT|GPT|Copilot|Cursor|Gemini|Codex|Devin|" - r"Windsurf|Codeium|Amazon Q|Tabnine|Cody|\[bot\]|github-actions|" - r"dependabot|renovate(?:\[bot\])?", +PRODUCT = re.compile( + r"(?")[0].strip() + name = COAUTHOR.sub("", name).strip() + return bool(PRODUCT.search(name) or PRODUCT.search(email) or BOT_DOMAIN.search(email) + or ASSISTANT_ALONE.fullmatch(name) or ASSISTANT_PRODUCT.search(name)) + + def commit_violations(commit, raw): header, separator, message = raw.partition(b"\n\n") if not separator: @@ -24,10 +43,10 @@ def commit_violations(commit, raw): return [f"{commit}: expected one author"] identity = authors[0].decode("utf-8", errors="replace") errors = [] - if BOT.search(identity): + if is_bot(identity): errors.append(f"{commit}: bot author: {identity}") for line in message.decode("utf-8", errors="replace").splitlines(): - if COAUTHOR.match(line) and BOT.search(line): + if COAUTHOR.match(line) and is_bot(line): errors.append(f"{commit}: bot co-author: {line.strip()}") return errors @@ -36,11 +55,11 @@ def event_violations(event): pr = event.get("pull_request", {}) user = pr.get("user", {}) errors = [] - if user.get("type") == "Bot" or BOT.search(user.get("login", "")): + if user.get("type") == "Bot" or is_bot(user.get("login", "")): errors.append("pull request: bot authorship is forbidden") for field in ("title", "body"): for line in (pr.get(field) or "").splitlines(): - if COAUTHOR.match(line) and BOT.search(line): + if COAUTHOR.match(line) and is_bot(line): errors.append(f"pull request {field}: bot co-author trailer") return errors diff --git a/tools/tests/test_authorship.py b/tools/tests/test_authorship.py index 03d0003b04..6734eb92dc 100644 --- a/tools/tests/test_authorship.py +++ b/tools/tests/test_authorship.py @@ -40,6 +40,27 @@ class AuthorshipTest(unittest.TestCase): def test_bot_pr_author_is_rejected(self): self.assertTrue(check.event_violations({"pull_request": {"user": {"login": "service", "type": "Bot"}}})) + def test_people_named_like_assistants_are_not_bots(self): + for author in ("Claudemirovsky <63046606+Claudemirovsky@users.noreply.github.com>", + "Claude Monet ", "Devin Smith ", + "Cody Allen ", "Gemini Patel "): + with self.subTest(author=author): + self.assertEqual([], check.commit_violations("abc", self.commit(author=author))) + self.assertEqual([], check.event_violations({"pull_request": {"user": {"login": "Claudemirovsky", "type": "User"}}})) + + def test_assistant_identities_are_still_bots(self): + for author in ("Claude Opus 5.5 ", "Claude Code ", + "Cursor Agent ", + "Devin AI ", + "Gemini ", "GPT-5 "): + with self.subTest(author=author): + self.assertTrue(check.commit_violations("abc", self.commit(author=author))) + for login in ("chatgpt-codex-connector", "Copilot", "claude"): + with self.subTest(login=login): + self.assertTrue(check.event_violations({"pull_request": {"user": {"login": login, "type": "User"}}})) + message = "Fix\n\nCo-authored-by: Claude Opus 5.5 \n" + self.assertEqual(1, len(check.commit_violations("abc", self.commit(message=message)))) + def test_missing_author_fails_closed(self): self.assertTrue(check.commit_violations("abc", b"tree 000\n\nmessage\n"))