From aba119ddd2c769c1e71d6b95f894c23d441d1a98 Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Wed, 25 Nov 2026 08:58:00 +0000 Subject: [PATCH] ci(pre-commit): refuse a plugins/ directory and agent co-author trailers 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 --- .pre-commit-config.yaml | 21 +++++++++++++++++++++ AGENTS.md | 4 ++-- docs/contributing/ai-assistance.md | 4 ++-- 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1f9d8b5..cbef59c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -114,6 +114,16 @@ repos: require_serial: true stages: ['pre-push'] + # SECURITY.md's accepted risks rest on the Collection shipping roles only. It sits before + # ansible-lint, whose fail_fast would otherwise hide this message. + - id: refuse-plugins + name: Refuse a plugins/ directory + description: refuse any file under plugins/ + entry: the Collection holds roles only; a plugin needs an ADR in docs/adr/ first, and that ADR's pull request removes this hook + language: fail + files: ^plugins/ + stages: ['pre-commit'] + - id: ansible-lint name: ansible-lint description: ansible-lint production profile, offline @@ -136,6 +146,17 @@ repos: files: (?i)(^|/)(\.claude/)?claude(\.local)?\.md$ stages: ['pre-commit'] + # Agent tools write these trailers by default. pygrep prints only the hook's name and the + # matching line, so the name carries the rule. Claude is also a person's name, so it matches + # only as a trailer's whole name ("Claude <"); a human Co-Authored-By: stays allowed. + - id: refuse-agent-trailers + name: "Agent work carries Assisted-by: [:], never an agent Co-Authored-By: or a session link (docs/contributing/ai-assistance.md)" + description: refuse Claude-Session and Co-Authored-By lines naming a known agent identity + entry: '^(claude-session:|co-authored-by:\s*claude\s*<|co-authored-by:.*(noreply@anthropic\.com|\b(copilot|cursor|gemini|codex)\b))' + language: pygrep + args: [--ignore-case] + stages: [commit-msg] + - repo: meta hooks: - id: check-hooks-apply diff --git a/AGENTS.md b/AGENTS.md index 7c0a466..cef360d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -46,8 +46,8 @@ held: by a control (a named hook or check), by review, or aspirational (checked `Co-Authored-By:` for an agent, a session link or any other AI trailer** ([ai-assistance.md](docs/contributing/ai-assistance.md)). *Reason:* AI assistance is disclosed (principle 7), and an agent is not an author (principle 1). - *Held by:* review; the exclusion becomes a control when the commit-msg hook that refuses these - trailers lands (#272). + *Held by:* control in part: the `refuse-agent-trailers` commit-msg hook refuses `Claude-Session:` + and a `Co-Authored-By:` naming a known agent; review for the rest and for `Assisted-by:`. - **On conflict with a shared rule delivered by apm, this repository's `AGENTS.md` wins.** *Reason:* this repository's rules are reviewed here, for this repository. *Held by:* aspirational. diff --git a/docs/contributing/ai-assistance.md b/docs/contributing/ai-assistance.md index 1497332..b6a7d6b 100644 --- a/docs/contributing/ai-assistance.md +++ b/docs/contributing/ai-assistance.md @@ -33,8 +33,8 @@ contributor docs are held by review until an offline link check exists. Terms su History is not rewritten. *Reason:* a co-author trailer makes the tool an author, and a session link is private and points outside this repository. - *Held by:* review until the commit-msg hook that refuses these trailers lands (issue #272); then - control. + *Held by:* control in part: the `refuse-agent-trailers` commit-msg hook refuses `Claude-Session:` + and a `Co-Authored-By:` naming a known agent; review for the rest. ## What agents may do -- 2.43.0