CheckPatch: accept required AI attribution diagnostics
RFC PATCH 1/1 CheckPatch: accept required AI attribution diagnostics
Recognize legacy signature errors only for one well-formed Assisted-by trailer at its exact patch path and commit-message line. Keep the raw diagnostics in the result and leave patch bytes unchanged.
Fail checker exits without a recognized diagnostic instead of reporting success. Test attribution formats, source errors, missing sign-offs and both orderings of mixed passing and failing patches.
---
Reported CI: https://github.com/bluez/bluetooth-next/pull/1084
Local validation: 18 checker tests pass. Both exact signed v8 patches fail with the original checker and pass with this change, byte-for-byte. Source, sign-off and mixed-series failures remain fatal.
ci/checkpatch.py | 55 ++++++++- tests/test_checkpatch.py | 243 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 295 insertions(+), 3 deletions(-) create mode 100644 tests/test_checkpatch.py
ci/checkpatch.py +52 -3
@@ -1,4 +1,5 @@ import os +import re import sys sys.path.insert(0, '../libs')
@@ -6,6 +7,39 @@ from libs import cmd_run from ci import Base, Verdict, EndTest, submit_pw_check + +def assisted_by_only(patch_file, ret, stdout, stderr): + """Recognize only legacy checkpatch diagnostics on AI attribution.""" + if ret != 1 or stderr.strip(): + return False + + with open(patch_file, encoding='utf-8', errors='replace') as patch: + message = re.split(r'^---(?:\s.*)?$|^diff --git ', patch.read(), + maxsplit=1, flags=re.MULTILINE)[0] + + trailers = [(number, line) + for number, line in enumerate(message.splitlines(), 1) + if line.startswith('Assisted-by:')] + if len(trailers) != 1: + return False + + number, trailer = trailers[0] + match = re.fullmatch(r'Assisted-by: (LLM|[\w.+-]+:[\w.+-]+(?: [\w.+-]+)*)', + trailer, flags=re.ASCII) + if not match: + return False + value = match.group(1) + + prefix = f'{patch_file}:{number}: ' + allowed = { + prefix + 'WARNING:BAD_SIGN_OFF: Non-standard signature: Assisted-by:', + prefix + f"ERROR:BAD_SIGN_OFF: Unrecognized email address: '{value}'", + } + diagnostics = [line for line in stdout.splitlines() if line] + return (bool(diagnostics) and len(diagnostics) == len(set(diagnostics)) + and set(diagnostics) <= allowed) + + class CheckPatch(Base): """Check Patch class This class runs the checkpatch.pl with the patches in the series.
@@ -41,9 +75,13 @@ class CheckPatch(Base): if ret == 0: # CheckPatch PASS self.log_dbg("Test result PASSED") + details = "CheckPatch PASS" + if stdout.strip(): + details += "\n" + stdout + self.output += f"{patch['name']}\n{stdout}\n" submit_pw_check(self.ci_data.pw, patch, self.name, Verdict.PASS, - "CheckPatch PASS", + details, None, self.ci_data.config['dry_run']) continue
@@ -69,6 +107,12 @@ class CheckPatch(Base): self.add_failure(msg) continue + # A failed checker without a recognized diagnostic still fails. + submit_pw_check(self.ci_data.pw, patch, + self.name, Verdict.FAIL, outstr, + None, self.ci_data.config['dry_run']) + self.add_failure(msg) + # Overall result if self.verdict == Verdict.FAIL: self.log_info(f"Test Verdict: {self.verdict.name}")
@@ -78,7 +122,7 @@ class CheckPatch(Base): self.log_info(f"Test Verdict: {self.verdict.name}") def _checkpatch(self, patch): - cmd = [self.checkpatch_pl] + cmd = [self.checkpatch_pl, '--show-types', '--terse', '--no-summary'] if self.ignore: cmd.append('--ignore') cmd.append(self.ignore)
@@ -88,7 +132,12 @@ class CheckPatch(Base): f"{patch['id']}.patch")) self.log_dbg(f"Patch file: {patch_file}") cmd.append(patch_file) - return cmd_run(cmd, cwd=self.ci_data.src_dir) + ret, stdout, stderr = cmd_run(cmd, cwd=self.ci_data.src_dir) + if assisted_by_only(patch_file, ret, stdout, stderr): + stdout = ("Accepted required Assisted-by metadata diagnostics; " + "attribution preserved:\n" + stdout) + return 0, stdout, stderr + return ret, stdout, stderr def post_run(self): self.log_dbg("Post Run...")
tests/test_checkpatch.py new file +243 -0
243 lines not on this page · raw message
base-commit: 60348956fc7bad52a64e802f3e90f90c03ba8860
Signature · 1 line
2.56.0