diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index c261ce31e4..e9ea8439f6 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -26,6 +26,8 @@
# Reviewer routing registry and helper
/REVIEWERS.md @ai-openshell/maintainers
+/tasks/scripts/check_commit_policy.py @ai-openshell/maintainers
+/tasks/scripts/check_commit_policy_test.py @ai-openshell/maintainers
/tasks/scripts/check_review_readiness.py @ai-openshell/maintainers
/tasks/scripts/check_review_readiness_test.py @ai-openshell/maintainers
diff --git a/.github/workflows/branch-checks.yml b/.github/workflows/branch-checks.yml
index 52ad9f1fb7..3c3a756918 100644
--- a/.github/workflows/branch-checks.yml
+++ b/.github/workflows/branch-checks.yml
@@ -610,7 +610,28 @@ jobs:
run: mise run test:qualification-summary
- name: Test accepted-work library, review-readiness, and issue labeling
- run: "mise run test:accepted-work ::: test:review-readiness ::: test:label-issue"
+ run: "mise run test:accepted-work ::: test:review-readiness ::: test:label-issue ::: test:commit-policy"
+
+ commit-policy:
+ # Commits are checked while the author can still fix them. Merge queue runs
+ # skip this job; the PR already passed it and the queue creates its own
+ # merge commits.
+ name: Commit Policy
+ if: github.event_name == 'pull_request'
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ steps:
+ - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
+ with:
+ persist-credentials: false
+
+ - name: Check commit signing and agent attribution
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ GH_REPO: ${{ github.repository }}
+ PR_NUMBER: ${{ github.event.pull_request.number }}
+ run: python3 tasks/scripts/check_commit_policy.py --repo "$GH_REPO" --pr "$PR_NUMBER"
+
python-sdk-freeze:
# The Python SDK moved to ai-openshell/sdk-python (#5287), which imported it
# at v0.1.7. Its files stay only until core removes them, so PRs must not
diff --git a/CI.md b/CI.md
index 81f243d7cb..17de1f4e6d 100644
--- a/CI.md
+++ b/CI.md
@@ -600,6 +600,10 @@ operating-system CVEs remain the responsibility of the standalone scan.
Org members and collaborators sign their commits cryptographically.
+The `Commit Policy` check enforces this on pull requests. It fails when a commit by an author with write or admin access is not GitHub-verified. External contributors and bots are exempt. To fix a failure, set up signing as described below, then re-sign the commits (for example `git rebase --exec 'git commit --amend --no-edit -S' `) and push.
+
+The same check fails when a commit message, the PR title, or the PR body carries a `Co-authored-by:` trailer or a "Generated with" footer that names an AI agent, for every author. Remove the trailer or footer; see the Commits section of [AGENTS.md](AGENTS.md).
+
DCO sign-off (`-s` / `Signed-off-by`) is a separate requirement and does not count as commit signing. Dependabot-authored dependency update PRs are allowlisted in DCO Assistant because the bot cannot sign commits.
### One-time setup with an SSH key
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8409bba1a9..245b460f9d 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -602,7 +602,7 @@ git commit --signoff --message "feat(sandbox): add new capability"
DCO sign-off is separate from cryptographic commit signing, and the two have different requirements:
- **DCO sign-off** (`--signoff`) adds the `Signed-off-by` trailer to each commit. It applies to every contributor. The DCO Assistant bot also asks you to sign the DCO once, by commenting on your PR.
-- **Cryptographic commit signing** applies to org members and collaborators only; see [CI.md](CI.md#commit-signing) for setup.
+- **Cryptographic commit signing** applies to org members and collaborators only, and the `Commit Policy` check enforces it. That check also rejects `Co-authored-by:` trailers and "Generated with" footers that name an AI agent. See [CI.md](CI.md#commit-signing) for setup and fixes.
### PR testing checklist
diff --git a/tasks/scripts/check_commit_policy.py b/tasks/scripts/check_commit_policy.py
new file mode 100644
index 0000000000..c826c7a764
--- /dev/null
+++ b/tasks/scripts/check_commit_policy.py
@@ -0,0 +1,130 @@
+#!/usr/bin/env python3
+# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+"""Enforce commit signing and reject agent attribution on a pull request.
+
+Signing applies to commits whose author has write or admin access to the
+repository. External contributors and bots are exempt. Attribution applies to
+every commit message, the PR title, and the PR body.
+"""
+
+from __future__ import annotations
+
+import argparse
+import re
+import subprocess
+import sys
+from typing import TYPE_CHECKING
+
+from check_review_readiness import _api
+
+if TYPE_CHECKING:
+ from collections.abc import Callable
+
+AGENT = re.compile(
+ r"\b(?:claude|anthropic|copilot|codex|cursor|gemini|chatgpt|openai|devin|aider)\b",
+ re.IGNORECASE,
+)
+CO_AUTHOR = re.compile(r"^[ \t]*co-authored-by:(.*)$", re.IGNORECASE | re.MULTILINE)
+GENERATED = re.compile(r"^.*\bgenerated (?:with|by)\b.*$", re.IGNORECASE | re.MULTILINE)
+SIGNING_PERMISSIONS = {"write", "admin"}
+
+
+def attribution_problems(text: str) -> list[str]:
+ """Name each kind of agent attribution found in `text`."""
+ problems = []
+ if any(AGENT.search(match.group(1)) for match in CO_AUTHOR.finditer(text)):
+ problems.append("Co-authored-by trailer names an AI agent; see AGENTS.md")
+ if any(AGENT.search(match.group(0)) for match in GENERATED.finditer(text)):
+ problems.append("'Generated with' footer names an AI agent; see AGENTS.md")
+ return problems
+
+
+def _is_bot(author: dict) -> bool:
+ return author.get("type") == "Bot" or str(author.get("login", "")).endswith("[bot]")
+
+
+def signing_problem(commit: dict, permission_of: Callable[[str], str]) -> str | None:
+ """Return why `commit` violates the signing rule, or None if it complies."""
+ author = commit.get("author") or {}
+ login = author.get("login")
+ if not login or _is_bot(author):
+ return None
+ verification = commit["commit"].get("verification") or {}
+ if verification.get("verified"):
+ return None
+ if permission_of(login) not in SIGNING_PERMISSIONS:
+ return None
+ reason = verification.get("reason", "unknown")
+ return (
+ f"not cryptographically signed (GitHub reports: {reason}); "
+ "see CI.md#commit-signing"
+ )
+
+
+def find_problems(
+ pull: dict, commits: list[dict], permission_of: Callable[[str], str]
+) -> list[str]:
+ """Return one line per violation across the PR text and its commits."""
+ problems = []
+ for label, text in (("PR title", pull.get("title")), ("PR body", pull.get("body"))):
+ problems += [f"{label}: {p}" for p in attribution_problems(text or "")]
+ for commit in commits:
+ sha = commit["sha"][:9]
+ problem = signing_problem(commit, permission_of)
+ if problem:
+ problems.append(f"{sha} {problem}")
+ message = commit["commit"].get("message", "")
+ problems += [f"{sha} {p}" for p in attribution_problems(message)]
+ return problems
+
+
+def _permission(repo: str, login: str) -> str:
+ try:
+ return _api(f"repos/{repo}/collaborators/{login}/permission")["permission"]
+ except subprocess.CalledProcessError as exc:
+ if "404" in (exc.stderr or ""):
+ return "none"
+ raise
+
+
+def main(argv: list[str] | None = None) -> int:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("--repo", required=True)
+ parser.add_argument("--pr", required=True, type=int)
+ args = parser.parse_args(argv)
+ cache: dict[str, str] = {}
+
+ def permission_of(login: str) -> str:
+ key = login.lower()
+ if key not in cache:
+ cache[key] = _permission(args.repo, login)
+ return cache[key]
+
+ try:
+ pull = _api(f"repos/{args.repo}/pulls/{args.pr}")
+ commits = _api(
+ f"repos/{args.repo}/pulls/{args.pr}/commits?per_page=100", pages=True
+ )
+ problems = find_problems(pull, commits, permission_of)
+ except subprocess.CalledProcessError as exc:
+ print(
+ "Cannot verify commit policy: " + (exc.stderr or str(exc)).strip(),
+ file=sys.stderr,
+ )
+ return 1
+ except (KeyError, TypeError, ValueError) as exc:
+ print(f"Commit policy: unexpected GitHub response: {exc}", file=sys.stderr)
+ return 1
+ if problems:
+ print(f"Commit Policy: {len(problems)} problem(s)", file=sys.stderr)
+ for problem in problems:
+ print(f" {problem}", file=sys.stderr)
+ return 1
+ print(f"All {len(commits)} commits and the PR text meet the commit policy.")
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/tasks/scripts/check_commit_policy_test.py b/tasks/scripts/check_commit_policy_test.py
new file mode 100644
index 0000000000..fafd0d8a9f
--- /dev/null
+++ b/tasks/scripts/check_commit_policy_test.py
@@ -0,0 +1,175 @@
+# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
+# SPDX-License-Identifier: Apache-2.0
+
+import io
+import subprocess
+import unittest
+from contextlib import redirect_stderr, redirect_stdout
+from unittest import mock
+
+import check_commit_policy as policy
+
+
+def commit(sha="a" * 40, login="alice", verified=True, message="fix: thing", **author):
+ return {
+ "sha": sha,
+ "author": {"login": login, **author} if login else None,
+ "commit": {
+ "message": message,
+ "verification": {
+ "verified": verified,
+ "reason": "valid" if verified else "unsigned",
+ },
+ },
+ }
+
+
+def permissions(table):
+ return lambda login: table.get(login, "none")
+
+
+class SigningTests(unittest.TestCase):
+ def test_unsigned_collaborator_fails(self):
+ found = policy.find_problems(
+ {}, [commit(verified=False)], permissions({"alice": "write"})
+ )
+ self.assertEqual(len(found), 1)
+ self.assertIn("not cryptographically signed", found[0])
+ self.assertIn("unsigned", found[0])
+
+ def test_admin_is_covered(self):
+ found = policy.find_problems(
+ {}, [commit(verified=False)], permissions({"alice": "admin"})
+ )
+ self.assertEqual(len(found), 1)
+
+ def test_unsigned_external_contributor_passes(self):
+ self.assertEqual(
+ policy.find_problems({}, [commit(verified=False)], permissions({})), []
+ )
+
+ def test_read_permission_passes(self):
+ found = policy.find_problems(
+ {}, [commit(verified=False)], permissions({"alice": "read"})
+ )
+ self.assertEqual(found, [])
+
+ def test_unsigned_bot_passes(self):
+ bot = commit(login="dependabot[bot]", verified=False, type="Bot")
+ self.assertEqual(
+ policy.find_problems({}, [bot], permissions({"dependabot[bot]": "write"})),
+ [],
+ )
+
+ def test_unlinked_author_passes(self):
+ self.assertEqual(
+ policy.find_problems(
+ {}, [commit(login=None, verified=False)], permissions({})
+ ),
+ [],
+ )
+
+ def test_signed_commit_does_not_query_permission(self):
+ def fail(_login):
+ raise AssertionError("permission must not be looked up")
+
+ self.assertEqual(policy.find_problems({}, [commit()], fail), [])
+
+
+class AttributionTests(unittest.TestCase):
+ def test_agent_coauthor_in_commit_fails(self):
+ message = "feat: x\n\nCo-Authored-By: Claude Sonnet "
+ found = policy.find_problems({}, [commit(message=message)], permissions({}))
+ self.assertEqual(len(found), 1)
+ self.assertIn("Co-authored-by", found[0])
+
+ def test_human_coauthor_passes(self):
+ message = "feat: x\n\nCo-authored-by: Octo Cat "
+ self.assertEqual(
+ policy.find_problems({}, [commit(message=message)], permissions({})), []
+ )
+
+ def test_generated_with_footer_in_pr_body_fails(self):
+ pull = {
+ "title": "fix: x",
+ "body": "Done.\n\n🤖 Generated with [Claude Code](https://claude.com/claude-code)",
+ }
+ found = policy.find_problems(pull, [], permissions({}))
+ self.assertEqual(len(found), 1)
+ self.assertTrue(found[0].startswith("PR body:"))
+
+ def test_generated_with_unrelated_tool_passes(self):
+ pull = {"title": "chore: x", "body": "Types generated with protobuf."}
+ self.assertEqual(policy.find_problems(pull, [], permissions({})), [])
+
+ def test_agent_name_in_pr_title_trailer_fails(self):
+ pull = {"title": "fix: x\nCo-authored-by: Copilot", "body": None}
+ self.assertEqual(len(policy.find_problems(pull, [], permissions({}))), 1)
+
+ def test_agent_word_outside_trailer_passes(self):
+ message = "docs: explain how Claude Code reads AGENTS.md"
+ self.assertEqual(
+ policy.find_problems({}, [commit(message=message)], permissions({})), []
+ )
+
+
+class MainTests(unittest.TestCase):
+ def run_main(self, responses):
+ def fake_api(path, **_kwargs):
+ value = responses[path.split("?")[0]]
+ if isinstance(value, Exception):
+ raise value
+ return value
+
+ out, err = io.StringIO(), io.StringIO()
+ with (
+ mock.patch.object(policy, "_api", fake_api),
+ redirect_stdout(out),
+ redirect_stderr(err),
+ ):
+ code = policy.main(["--repo", "o/r", "--pr", "7"])
+ return code, out.getvalue(), err.getvalue()
+
+ def test_passes_for_clean_pr(self):
+ code, out, _ = self.run_main(
+ {
+ "repos/o/r/pulls/7": {"title": "fix: x", "body": ""},
+ "repos/o/r/pulls/7/commits": [commit()],
+ }
+ )
+ self.assertEqual(code, 0)
+ self.assertIn("meet the commit policy", out)
+
+ def test_reports_each_problem(self):
+ code, _, err = self.run_main(
+ {
+ "repos/o/r/pulls/7": {"title": "fix: x", "body": ""},
+ "repos/o/r/pulls/7/commits": [commit(verified=False)],
+ "repos/o/r/collaborators/alice/permission": {"permission": "write"},
+ }
+ )
+ self.assertEqual(code, 1)
+ self.assertIn("1 problem(s)", err)
+
+ def test_missing_collaborator_is_external(self):
+ not_found = subprocess.CalledProcessError(
+ 1, "gh", stderr="gh: Not Found (HTTP 404)"
+ )
+ code, _, _ = self.run_main(
+ {
+ "repos/o/r/pulls/7": {"title": "fix: x", "body": ""},
+ "repos/o/r/pulls/7/commits": [commit(verified=False)],
+ "repos/o/r/collaborators/alice/permission": not_found,
+ }
+ )
+ self.assertEqual(code, 0)
+
+ def test_api_failure_fails_closed(self):
+ boom = subprocess.CalledProcessError(1, "gh", stderr="HTTP 502")
+ code, _, err = self.run_main({"repos/o/r/pulls/7": boom})
+ self.assertEqual(code, 1)
+ self.assertIn("Cannot verify commit policy", err)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/tasks/test.toml b/tasks/test.toml
index b2e599241c..86fda7c9f3 100644
--- a/tasks/test.toml
+++ b/tasks/test.toml
@@ -29,6 +29,7 @@ depends = [
"test:merge-gateway-toml",
"test:accepted-work",
"test:label-issue",
+ "test:commit-policy",
]
["test:merge-gateway-toml"]
@@ -110,6 +111,11 @@ description = "Test PR review readiness and reviewer reconciliation"
run = "uv run --no-project python -m unittest discover -s tasks/scripts -p check_review_readiness_test.py"
hide = true
+["test:commit-policy"]
+description = "Test commit signing and agent attribution checks"
+run = "uv run --no-project python -m unittest discover -s tasks/scripts -p check_commit_policy_test.py"
+hide = true
+
["test:accepted-work"]
description = "Test the shared accepted-work library"
run = "uv run --no-project python -m unittest discover -s tasks/scripts -p label_accepted_work_test.py"