Skip to content

fix(git-guards): enforce kernel coding-assistants trailer spec#333

Merged
JacobPEvans-personal merged 2 commits into
mainfrom
fix/kernel-spec-commit-trailer
May 25, 2026
Merged

fix(git-guards): enforce kernel coding-assistants trailer spec#333
JacobPEvans-personal merged 2 commits into
mainfrom
fix/kernel-spec-commit-trailer

Conversation

@JacobPEvans-personal
Copy link
Copy Markdown
Member

@JacobPEvans-personal JacobPEvans-personal commented May 25, 2026

Summary

Enforce the kernel.org coding-assistants trailer spec: Assisted-by: Claude:<model> (e.g. Assisted-by: Claude:claude-opus-4-7). Rewrite incorrect forms (Assisted-by: Claude <email>, bare Assisted-by: Claude) and strip errant robot emoji lines from commits and PR description heredocs.

Changes

  • Trailer pattern refinement: Added word boundary (\b) to prevent false matches on names like "Claudette"; expanded pattern to capture bare Assisted-by: Claude and email form, rewriting both to spec-compliant format.
  • Robot emoji stripping: Added patterns to detect and remove 🤖 Generated with [Claude Code] lines from commit messages and gh pr create body heredocs, independent of transcript validation (never fails open).
  • Restructured main(): Robot stripping and trailer rewrites now follow separate code paths for clarity.
  • Improved diagnostics: Reason string now reports which transforms were applied.
  • Expanded test suite: Added 6 new test cases covering bare trailer, robot lines in commits, robot lines in PR bodies, combined scenarios, robot-strip-without-transcript, and Claudette word-boundary verification.

Test Plan

  • Run pytest git-guards/scripts/test_commit_trailer_guard.py — all 13 tests pass.
  • Verify test coverage: bare trailer rewrite (Tests 2–3), robot line removal from commits (Test 7), robot line removal from PR bodies (Tests 8–9), combined transforms (Test 10), robot strip without transcript (Test 11), Claudette negative case (Test 13).
  • Manual verification: commits with Assisted-by: Claude <noreply@anthropic.com> are rewritten to Assisted-by: Claude:<model>; bare Assisted-by: Claude trailers are rewritten; robot emoji lines are stripped from all sources.

…nd robot signature

- Expand TRAILER_PATTERN to match bare `Assisted-by: Claude` (no model)
  in addition to the existing email form `Assisted-by: Claude <...>`;
  already-correct `Assisted-by: Claude:<model>` is explicitly excluded
- Add robot-signature stripping: removes `🤖 Generated with [Claude Code]`
  lines (and the preceding blank line) from any Bash command — commits,
  PR body heredocs, etc. Blank-line variant replaced with \n to keep
  heredoc EOF delimiters on their own lines
- Restructure main() so robot strip and trailer fix are independent
  paths; robot strip is transcript-independent (never fails open)
- Update reason string to report which transforms were applied
- Add 5 new tests: bare trailer rewrite, robot line in commit, robot
  line in gh pr create, both combined, robot strip without transcript

Refs: https://docs.kernel.org/process/coding-assistants.html

Assisted-by: Claude:claude-opus-4-7
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the commit-trailer-guard.py script to enforce the kernel coding-assistants specification by rewriting bare or email-formatted Assisted-by: Claude trailers and stripping robot-signature lines. It also introduces comprehensive test cases for these scenarios. The review feedback highlights two important improvements: adding a word boundary (\b) to the TRAILER_PATTERN regular expression to prevent false-positive matches on names starting with "Claude" (such as "Claudette"), and adding corresponding test cases that utilize explicit assert statements to ensure CI failures on regressions.

Comment thread git-guards/scripts/commit-trailer-guard.py Outdated
Comment thread git-guards/scripts/test_commit_trailer_guard.py
…-prefixed names

Without \b after "Claude", the TRAILER_PATTERN incorrectly matched names
like "Assisted-by: Claudette <...>" via the negative-lookahead path.
Add \b so only the standalone word "Claude" matches.

Also add test 13: verifies "Claudette" is NOT rewritten (silent allow).

Assisted-by: Claude:claude-opus-4-7
@JacobPEvans-personal JacobPEvans-personal changed the title fix(git-guards): enforce kernel coding-assistants spec for trailers and robot signature fix(git-guards): enforce kernel coding-assistants trailer spec May 25, 2026
@JacobPEvans-personal JacobPEvans-personal merged commit 5eb30be into main May 25, 2026
6 checks passed
@JacobPEvans-personal JacobPEvans-personal deleted the fix/kernel-spec-commit-trailer branch May 25, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant