ci(pre-commit): refuse a plugins/ directory and agent co-author trailers #365

Merged
Defame1297 merged 1 commits from ci/272-refuse-plugins-and-agent-trailers into main 2026-11-25 10:02:00 +00:00
Owner

What and why

Closes #272

Two local hooks turn rules from #258 (items 2 and 4) into controls:

  • refuse-plugins (language: fail, files: ^plugins/). Its message is the rule: the Collection holds roles only, a plugin needs an ADR in docs/adr/ first, and that ADR's pull request removes this hook. It sits before ansible-lint, because that hook's fail_fast stopped the run before this message showed, which was seen in testing.
  • refuse-agent-trailers (language: pygrep, --ignore-case, commit-msg stage).
    • It refuses Claude-Session: lines.
    • It refuses Co-Authored-By: lines naming a known agent: [email protected], a trailer whose whole name is Claude <…>, or Copilot, Cursor, Gemini or Codex.
    • A human co-author passes, including one whose first name is Claude.
    • pygrep prints only the hook's name and the matching line, so the name carries the rule.
  • Docs. The trailer rule's Held by in AGENTS.md and docs/contributing/ai-assistance.md now names the hook as a control in part. Other AI trailers and the presence of Assisted-by: stay held by review.

Where this departs from the issue's wording:

  • No ci image version edit. scripts/bump_image_versions.py no longer exists. images/AGENTS.md now says a pull request that changes an image input needs no version edit, because next_image_version.py assigns it on main.
  • No dev-setup.sh change. default_install_hook_types already lists commit-msg, and the script installs it.
  • No docs edit owed for the roles-only rule. #258 dropped its root clause, so the hook is where the rule lives.
  • No changelog fragment. This is contributor tooling and consumers don't see it.

Verified

  • pygrep runs at the commit-msg stage. Checked first in a scratch repo, then here with pre-commit run refuse-agent-trailers --hook-stage commit-msg --commit-msg-filename <f> on 12 messages, all as expected:
  • git commit of a staged plugins/x.py fails with the rule as the message.
  • This commit's own message passed the new hook through the installed commit-msg hook.
  • pre-commit run --all-files passes, including check-hooks-apply (it exempts language: fail hooks) and check-useless-excludes.
  • ansible-test sanity passed through the pre-push hook.
  • The code-review skill ran both axes (standards and spec). Fixed from its findings:
    • The Held by lines overclaimed a full control; they now say control in part.
    • \bclaude\b refused a human co-author named Claude.
    • The plugins comment repeated the hook's message.

Not verified

  • CI doesn't re-check the new hook. Lint's "Check Conventional Commits" step (lint.yml:141) runs only conventional-pre-commit per pull request commit. refuse-agent-trailers is therefore skipped by --no-verify, by a clone without scripts/dev-setup.sh, and by commits made through the forge. Adding it to that loop is a one-line workflow change, left out of this pull request for the maintainer to decide.
  • Agents outside the listed identities pass, for example Devin, aider, Jules or another @anthropic.com address. The issue gave its list as examples. A trailer indented with spaces isn't matched either.
  • The post-merge ci image build. .pre-commit-config.yaml is an image input. The new hooks need no hook environment, but that build runs only on main.
  • Lint and Build in CI, which run on this pull request.

  • I confirm third-party material is recorded in NOTICE and REUSE.toml, or there is none.

Assisted-by: Claude Code

## What and why Closes #272 Two local hooks turn rules from #258 (items 2 and 4) into controls: - **`refuse-plugins`** (`language: fail`, `files: ^plugins/`). Its message is the rule: the Collection holds roles only, a plugin needs an ADR in `docs/adr/` first, and that ADR's pull request removes this hook. It sits before `ansible-lint`, because that hook's `fail_fast` stopped the run before this message showed, which was seen in testing. - **`refuse-agent-trailers`** (`language: pygrep`, `--ignore-case`, `commit-msg` stage). - It refuses `Claude-Session:` lines. - It refuses `Co-Authored-By:` lines naming a known agent: `[email protected]`, a trailer whose whole name is `Claude <…>`, or Copilot, Cursor, Gemini or Codex. - A human co-author passes, including one whose first name is Claude. - `pygrep` prints only the hook's name and the matching line, so the `name` carries the rule. - **Docs.** The trailer rule's *Held by* in `AGENTS.md` and `docs/contributing/ai-assistance.md` now names the hook as a **control in part**. Other AI trailers and the presence of `Assisted-by:` stay held by review. Where this departs from the issue's wording: - **No `ci` image version edit.** `scripts/bump_image_versions.py` no longer exists. `images/AGENTS.md` now says a pull request that changes an image input needs no version edit, because `next_image_version.py` assigns it on `main`. - **No `dev-setup.sh` change.** `default_install_hook_types` already lists `commit-msg`, and the script installs it. - **No docs edit owed for the roles-only rule.** #258 dropped its root clause, so the hook is where the rule lives. - **No changelog fragment.** This is contributor tooling and consumers don't see it. ## Verified - `pygrep` runs at the `commit-msg` stage. Checked first in a scratch repo, then here with `pre-commit run refuse-agent-trailers --hook-stage commit-msg --commit-msg-filename <f>` on 12 messages, all as expected: - **Refused:** `Co-Authored-By: Claude <[email protected]>`, `Claude Opus 5.5 <[email protected]>`, `Claude <[email protected]>`, `Claude-Session: …`, GitHub Copilot, Cursor Agent, Gemini, Codex. - **Passed:** a human `Co-Authored-By:`, `Claude Dupont <[email protected]>`, `Jane Cursorsmith`, `Assisted-by: Claude Code`. - `git commit` of a staged `plugins/x.py` fails with the rule as the message. - This commit's own message passed the new hook through the installed `commit-msg` hook. - `pre-commit run --all-files` passes, including `check-hooks-apply` (it exempts `language: fail` hooks) and `check-useless-excludes`. - `ansible-test sanity` passed through the pre-push hook. - The `code-review` skill ran both axes (standards and spec). Fixed from its findings: - The *Held by* lines overclaimed a full control; they now say control in part. - `\bclaude\b` refused a human co-author named Claude. - The plugins comment repeated the hook's message. ## Not verified - **CI doesn't re-check the new hook.** Lint's "Check Conventional Commits" step (`lint.yml:141`) runs only `conventional-pre-commit` per pull request commit. `refuse-agent-trailers` is therefore skipped by `--no-verify`, by a clone without `scripts/dev-setup.sh`, and by commits made through the forge. Adding it to that loop is a one-line workflow change, left out of this pull request for the maintainer to decide. - **Agents outside the listed identities pass**, for example Devin, aider, Jules or another `@anthropic.com` address. The issue gave its list as examples. A trailer indented with spaces isn't matched either. - **The post-merge `ci` image build.** `.pre-commit-config.yaml` is an image input. The new hooks need no hook environment, but that build runs only on `main`. - **Lint and Build in CI**, which run on this pull request. --- - [x] I confirm third-party material is recorded in `NOTICE` and `REUSE.toml`, or there is none. Assisted-by: Claude Code
Claude added this to the Open to contributors milestone 2026-11-25 09:15:39 +00:00
Defame1297 was assigned by Claude 2026-11-25 09:15:39 +00:00
Claude added 1 commit 2026-11-25 09:15:39 +00:00
ci(pre-commit): refuse a plugins/ directory and agent co-author trailers
Build / build (pull_request) Successful in 19s
Molecule / molecule (pull_request) Successful in 1m9s
Lint / lint (pull_request) Successful in 2m6s
aba119ddd2
Two local hooks hold rules that review held until now:

- refuse-plugins (language: fail, ^plugins/): the Collection holds roles
  only; a plugin needs an ADR first, whose pull request removes the hook.
  It runs before ansible-lint so that hook's fail_fast cannot hide it.
- refuse-agent-trailers (pygrep, commit-msg stage): refuses Claude-Session:
  and Co-Authored-By: lines naming a known agent identity. A human
  co-author passes, including one whose first name is Claude. The hook
  name carries the rule, since pygrep prints no other message.

AGENTS.md and ai-assistance.md name the hook as a partial control of the
trailer rule; other AI trailers stay held by review.

Closes #272

Assisted-by: Claude Code
CODEOWNERS rules requested review from Defame1297 2026-11-25 09:15:40 +00:00
Defame1297 approved these changes 2026-11-25 10:01:57 +00:00
Defame1297 merged commit 4ec685b4f6 into main 2026-11-25 10:02:00 +00:00
Defame1297 deleted branch ci/272-refuse-plugins-and-agent-trailers 2026-11-25 10:02:01 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Mortis/Kamino#365