Skip to contentSkip to conversation

checkpatch: reject trailers that credit an AI agent

PATCH In review Paolo Bonzini 5 participants 9 messages Sep 3 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 checkpatch: reject trailers that credit an AI agent

The QEMU community has broad consent to not accept assisted-by and similar trailers, and much less fake co-authored-bys, independent of any AI policy. Implement this in checkpatch.pl already, so that there is another way for contributors to discover the AI policy.

---
 scripts/checkpatch.pl | 12 ++++++++++++
 1 file changed, 12 insertions(+)
scripts/checkpatch.pl +12 -0
index 03f35e75012..90cb40dfe1f 100755
@@ -1811,6 +1811,18 @@ sub process {
 			}
 		}
 
+# Reject trailers that credit an AI agent.
+		if ($realfile =~ /^$/ &&
+		    ($line =~ /🤖/ ||
+		     $line =~ /^\s*(?:Assisted|Generated)-by:/i ||
+		     ($line =~ /^\s*Co-authored-by:\s*(.*?)\s*$/i &&
+		      $1 =~ /\bcopilot\b | \bchatgpt\b | \bcodex\b | \bcursor\b | \[bot\] |
+			     \bllama\b | \bgemini\b.*(?:pro|flash|ultra|google\.com) |
+			     \bclaude\b.*(?:opus|sonnet|fable|haiku|anthropic\.com)/xi))) {
+			ERROR("QEMU does not allow using AI for contributions, " .
+				"see docs/devel/code-provenance.rst\n" . $herecurr);
+		}
+
 # Check SPDX-License-Identifier references a permitted license
 		if (($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) &&
 			$rawline !~ /^-/) {
Signature · 1 line
2.55.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 16 lines · Paolo Bonzini

The QEMU community has broad consent to not accept assisted-by and similar trailers, and much less fake co-authored-bys, independent of any AI policy. Implement this in checkpatch.pl already, so that there is another way for contributors to discover the AI policy.

---
 scripts/checkpatch.pl | 12 ++++++++++++
 1 file changed, 12 insertions(+)
scripts/checkpatch.pl +0 -0
index 03f35e75012..90cb40dfe1f 100755

scripts/checkpatch.pl sub process { · line 1816

Quoted 6 lines
scripts/checkpatch.pl +3 -0
@@ -1811,6 +1811,18 @@ sub process {
 			}
 		}
 
+# Reject trailers that credit an AI agent.
+		if ($realfile =~ /^$/ &&
+		    ($line =~ /🤖/ ||

Oh wow, is that something people actually do :-)

scripts/checkpatch.pl sub process { · line 1821

Quoted 5 lines
scripts/checkpatch.pl +5 -0
+		     $line =~ /^\s*(?:Assisted|Generated)-by:/i ||
+		     ($line =~ /^\s*Co-authored-by:\s*(.*?)\s*$/i &&
+		      $1 =~ /\bcopilot\b | \bchatgpt\b | \bcodex\b | \bcursor\b | \[bot\] |
+			     \bllama\b | \bgemini\b.*(?:pro|flash|ultra|google\.com) |
+			     \bclaude\b.*(?:opus|sonnet|fable|haiku|anthropic\.com)/xi))) {

I presume the qualifiers after gemini/claude are a mitigation against accidentally matching a real person's name ?

scripts/checkpatch.pl sub process { · line 1824

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+			ERROR("QEMU does not allow using AI for contributions, " .
+				"see docs/devel/code-provenance.rst\n" . $herecurr);
+		}

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
#2 lore raw
Quoted 5 lines · Daniel P. Berrangé

scripts/checkpatch.pl sub process { · line 1816

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+# Reject trailers that credit an AI agent.
+		if ($realfile =~ /^$/ &&
+		    ($line =~ /🤖/ ||

Oh wow, is that something people actually do :-)

IIRC it's more in pull requests but it was fun to add.

Quoted 8 lines

scripts/checkpatch.pl sub process { · line 1821

Quoted 5 lines
scripts/checkpatch.pl +5 -0
+		     $line =~ /^\s*(?:Assisted|Generated)-by:/i ||
+		     ($line =~ /^\s*Co-authored-by:\s*(.*?)\s*$/i &&
+		      $1 =~ /\bcopilot\b | \bchatgpt\b | \bcodex\b | \bcursor\b | \[bot\] |
+			     \bllama\b | \bgemini\b.*(?:pro|flash|ultra|google\.com) |
+			     \bclaude\b.*(?:opus|sonnet|fable|haiku|anthropic\.com)/xi))) {

I presume the qualifiers after gemini/claude are a mitigation against accidentally matching a real person's name ?

For Claude yes, for Gemini I guess it's not really needed. BTW I have no idea which coding harnesses use Co-authored-by specifically so this is really just a guess.

Paolo

Quoted 9 lines

scripts/checkpatch.pl sub process { · line 1824

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+			ERROR("QEMU does not allow using AI for contributions, " .
+				"see docs/devel/code-provenance.rst\n" . $herecurr);
+		}

With regards,
Daniel

#3 lore raw
Quoted 18 lines · Paolo Bonzini
Quoted 5 lines · Daniel P. Berrangé

scripts/checkpatch.pl sub process { · line 1816

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+# Reject trailers that credit an AI agent.
+		if ($realfile =~ /^$/ &&
+		    ($line =~ /🤖/ ||

Oh wow, is that something people actually do :-)

IIRC it's more in pull requests but it was fun to add.

Quoted 8 lines

scripts/checkpatch.pl sub process { · line 1821

Quoted 5 lines
scripts/checkpatch.pl +5 -0
+		     $line =~ /^\s*(?:Assisted|Generated)-by:/i ||
+		     ($line =~ /^\s*Co-authored-by:\s*(.*?)\s*$/i &&
+		      $1 =~ /\bcopilot\b | \bchatgpt\b | \bcodex\b | \bcursor\b | \[bot\] |
+			     \bllama\b | \bgemini\b.*(?:pro|flash|ultra|google\.com) |
+			     \bclaude\b.*(?:opus|sonnet|fable|haiku|anthropic\.com)/xi))) {

I presume the qualifiers after gemini/claude are a mitigation against accidentally matching a real person's name ?

Quoted 3 lines

For Claude yes, for Gemini I guess it's not really needed. BTW I have no idea which coding harnesses use Co-authored-by specifically so this is really just a guess.

I expect Co-authored-by is often added by the contributor themselves

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
#4 lore raw
Quoted 5 lines · Daniel P. Berrangé
Quoted 3 lines

For Claude yes, for Gemini I guess it's not really needed. BTW I have no idea which coding harnesses use Co-authored-by specifically so this is really just a guess.

I expect Co-authored-by is often added by the contributor themselves

$ strings ~/bin/codex |grep -i Co-authored-by
- Commit messages must end with `Co-authored-by: Codex <[email protected]>`.

Straight from the system prompt. *puke*

Claude Code also has "Co-Authored-By: ${d3o(at())} <[email protected]>"

Adding "noreply" to the list is probably a good idea too.

Paolo

#5 lore raw
In reply to Paolo Bonzini

Hi

Quoted 26 lines · Paolo Bonzini

The QEMU community has broad consent to not accept assisted-by and similar trailers, and much less fake co-authored-bys, independent of any AI policy. Implement this in checkpatch.pl already, so that there is another way for contributors to discover the AI policy.

---
 scripts/checkpatch.pl | 12 ++++++++++++
 1 file changed, 12 insertions(+)
scripts/checkpatch.pl +6 -0
index 03f35e75012..90cb40dfe1f 100755
@@ -1811,6 +1811,18 @@ sub process {
                        }
                }
 
+# Reject trailers that credit an AI agent.
+               if ($realfile =~ /^$/ &&
+                   ($line =~ /🤖/ ||
+                    $line =~ /^\s*(?:Assisted|Generated)-by:/i ||
+                    ($line =~ /^\s*Co-authored-by:\s*(.*?)\s*$/i &&
+                     $1 =~ /\bcopilot\b | \bchatgpt\b | \bcodex\b | \bcursor\b | \[bot\] |

scripts/checkpatch.pl sub process {

Quoted 10 lines
scripts/checkpatch.pl +6 -1
+                            \bllama\b | \bgemini\b.*(?:pro|flash|ultra|google\.com) |
+                            \bclaude\b.*(?:opus|sonnet|fable|haiku|anthropic\.com)/xi))) {
+                       ERROR("QEMU does not allow using AI for contributions, " .
+                               "see docs/devel/code-provenance.rst\n" . $herecurr);
+               }
+
 # Check SPDX-License-Identifier references a permitted license
                if (($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) &&
                        $rawline !~ /^-/) {
--

lgtm,
on subject of trailer checks, I would also kindly ask for review:
https://patchew.org/QEMU/[email protected]/

thanks!

Signature · 1 line
Marc-André Lureau
#6 lore raw
In reply to Paolo Bonzini
Quoted 16 lines · Paolo Bonzini

The QEMU community has broad consent to not accept assisted-by and similar trailers, and much less fake co-authored-bys, independent of any AI policy. Implement this in checkpatch.pl already, so that there is another way for contributors to discover the AI policy.

---
  scripts/checkpatch.pl | 12 ++++++++++++
  1 file changed, 12 insertions(+)
scripts/checkpatch.pl +0 -0
index 03f35e75012..90cb40dfe1f 100755

scripts/checkpatch.pl sub process { · line 1816

Quoted 6 lines
scripts/checkpatch.pl +3 -0
@@ -1811,6 +1811,18 @@ sub process {
  			}
  		}
 
+# Reject trailers that credit an AI agent.
+		if ($realfile =~ /^$/ &&
+		    ($line =~ /🤖/ ||

Few years ago Peter was concerned about using non-ASCII because it was not displaying correctly on his terminal:
https://lore.kernel.org/qemu-devel/CAFEAcA-CJwcE9k+TqQ-vDrevzZPV_+CXAr1j9QfR_ivJTJ3e2w@mail.gmail.com/
(that was using Ubuntu 22.04 which we don't support anymore). Should we still worry about non-ASCII in the repository? Having a quick look at the OS versions we support it seems all of them are ready to handle UTF-8 chars. Anyway I saw various utf-8 emoji symbols in gitlab issues, and it is likely someone will paste one along with the report when filling commit description for a fix, so they'll end up displayed in a terminal via git-log.

Quoted 12 lines
scripts/checkpatch.pl +9 -0
+		     $line =~ /^\s*(?:Assisted|Generated)-by:/i ||
+		     ($line =~ /^\s*Co-authored-by:\s*(.*?)\s*$/i &&
+		      $1 =~ /\bcopilot\b | \bchatgpt\b | \bcodex\b | \bcursor\b | \[bot\] |
+			     \bllama\b | \bgemini\b.*(?:pro|flash|ultra|google\.com) |
+			     \bclaude\b.*(?:opus|sonnet|fable|haiku|anthropic\.com)/xi))) {
+			ERROR("QEMU does not allow using AI for contributions, " .
+				"see docs/devel/code-provenance.rst\n" . $herecurr);
+		}
+
  # Check SPDX-License-Identifier references a permitted license
  		if (($rawline =~ m,SPDX-License-Identifier: (.*?)(\*/)?\s*$,) &&
  			$rawline !~ /^-/) {
#7 lore raw

Hi

Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 19 lines · Paolo Bonzini

The QEMU community has broad consent to not accept assisted-by and similar trailers, and much less fake co-authored-bys, independent of any AI policy. Implement this in checkpatch.pl already, so that there is another way for contributors to discover the AI policy.

---
  scripts/checkpatch.pl | 12 ++++++++++++
  1 file changed, 12 insertions(+)
scripts/checkpatch.pl +0 -0
index 03f35e75012..90cb40dfe1f 100755
@@ -1811,6 +1811,18 @@ sub process {
                      }
              }
 
Quoted 15 lines

scripts/checkpatch.pl sub process { · line 1816

Quoted 3 lines
scripts/checkpatch.pl +3 -0
+# Reject trailers that credit an AI agent.
+             if ($realfile =~ /^$/ &&
+                 ($line =~ /🤖/ ||

Few years ago Peter was concerned about using non-ASCII because it was not displaying correctly on his terminal:
https://lore.kernel.org/qemu-devel/CAFEAcA-CJwcE9k+TqQ-vDrevzZPV_+CXAr1j9QfR_ivJTJ3e2w@mail.gmail.com/
(that was using Ubuntu 22.04 which we don't support anymore). Should we still worry about non-ASCII in the repository? Having a quick look at the OS versions we support it seems all of them are ready to handle UTF-8 chars. Anyway I saw various utf-8 emoji symbols in gitlab issues, and it is likely someone will paste one along with the report when filling commit description for a fix, so they'll end up displayed in a terminal via git-log.

Some projects actually enforce the usage of emoji in commit messages/titles (Zeeshan's projects, at least). I personally don't care. It can help, sure, just like icons do. I would much rather have tags to help classify commits and allow people to display them however they like, with some tools, though. For that, conventional commits help somewhat. Just my 2c

Signature · 1 line
Marc-André Lureau
#8 lore raw
In reply to Philippe Mathieu-Daudé
Quoted 11 lines · Philippe Mathieu-Daudé

scripts/checkpatch.pl sub process { · line 1816

Quoted 8 lines · Paolo Bonzini

The QEMU community has broad consent to not accept assisted-by and similar trailers, and much less fake co-authored-bys, independent of any AI policy. Implement this in checkpatch.pl already, so that there is another way for contributors to discover the AI policy.

scripts/checkpatch.pl +3 -0
+# Reject trailers that credit an AI agent.
+             if ($realfile =~ /^$/ &&
+                 ($line =~ /🤖/ ||
Quoted 10 lines

Few years ago Peter was concerned about using non-ASCII because it was not displaying correctly on his terminal:
https://lore.kernel.org/qemu-devel/CAFEAcA-CJwcE9k+TqQ-vDrevzZPV_+CXAr1j9QfR_ivJTJ3e2w@mail.gmail.com/
(that was using Ubuntu 22.04 which we don't support anymore). Should we still worry about non-ASCII in the repository? Having a quick look at the OS versions we support it seems all of them are ready to handle UTF-8 chars. Anyway I saw various utf-8 emoji symbols in gitlab issues, and it is likely someone will paste one along with the report when filling commit description for a fix, so they'll end up displayed in a terminal via git-log.

An emoji in checkpatch because we're specifically looking for it is probably be fine. Though I guess it's implicitly assuming the user's locale is UTF-8, which I'm not sure it will be. We seem tu use \xNN escape sequences elsewhere in this script where we need to look for oddball non-ASCII, and that would be safer I guess.

In the thread above I was mostly pushing back because that was a suggestion of using an emoji in *an executable filename*, which is going to be exposed to many more people than a string in a script to be run by developers.

thanks
-- PMM