chore(hooks): make attribution gates tool-agnostic and wire roadmap into style

Conform to the vendor-neutral github-discipline canon: the commit-msg and
pre-commit hooks and check-style.sh now reject AI attribution for every
assistant (Codex, Copilot, Gemini, ChatGPT, OpenAI, Anthropic), not just
Claude and Cursor. The no-cursor-attribution workflow is excluded from the
file-content scan since it legitimately quotes the tokens to detect them.

Also wire scripts/check-roadmap.sh into check-style.sh (and grant the CI gates
step issues:read + a token for the epic-coverage query), per the rule that the
roadmap gate runs in the style check.
This commit is contained in:
Mihaela Mihaljevic 2026-06-08 01:42:07 +02:00
parent 1ae6680d94
commit 9e7576bd7e
5 changed files with 44 additions and 1 deletions

View File

@ -112,6 +112,18 @@ if printf '%s' "$CONTENT" | grep -qiE -- '@cursor\.com'; then
FAIL=1
fi
# Rule 5.1 is vendor-neutral: reject attribution for every AI assistant, not just
# Claude/Cursor. Vendor names live in a list so the hook stays tool-agnostic.
AI_VENDORS="Codex Copilot Gemini ChatGPT OpenAI Anthropic"
AI_PREFIXES='Co-Authored-By:|Co-authored-by:|Generated with|Generated by|with help from|Powered by'
for vendor in $AI_VENDORS; do
if printf '%s' "$CONTENT" | grep -qiE -- "(${AI_PREFIXES}) ${vendor}"; then
printf 'commit-msg: forbidden AI attribution for %s.\n' "$vendor" >&2
printf ' Rule: github-discipline.md Rule 5.1 (tool-agnostic)\n' >&2
FAIL=1
fi
done
# Author / committer identity must not be Cursor. git var resolves the exact
# identity (including --author / GIT_*_IDENT overrides) this commit will record.
for ident in "$(git var GIT_AUTHOR_IDENT 2>/dev/null)" "$(git var GIT_COMMITTER_IDENT 2>/dev/null)"; do

View File

@ -209,6 +209,17 @@ while IFS= read -r file; do
FAIL=1
fi
# Vendor-neutral AI attribution (Rule 5.1 covers every assistant).
AI_VENDORS="Codex Copilot Gemini ChatGPT OpenAI Anthropic"
AI_PREFIXES='Co-Authored-By:|Co-authored-by:|Generated with|Generated by|with help from|Powered by'
for vendor in $AI_VENDORS; do
if printf '%s' "$ADDED" | grep -qiE -- "(${AI_PREFIXES}) ${vendor}"; then
printf 'pre-commit: forbidden AI attribution for %s in staged %s.\n' "$vendor" "$file" >&2
printf ' Rule: github-discipline.md Rule 5.1 (tool-agnostic)\n' >&2
FAIL=1
fi
done
# AI-signature emoji check.
while IFS= read -r emoji; do
[ -z "$emoji" ] && continue

View File

@ -12,6 +12,7 @@ on:
permissions:
contents: read
issues: read
jobs:
macos:
@ -22,6 +23,8 @@ jobs:
- name: Install format and lint tools
run: brew install swiftformat swiftlint
- name: Repository gates
env:
GH_TOKEN: ${{ github.token }}
run: |
bash scripts/check-style.sh
bash scripts/check-namespacing.sh

View File

@ -18,7 +18,6 @@ run_gate() {
run_gate "style" bash scripts/check-style.sh
run_gate "namespacing" bash scripts/check-namespacing.sh
run_gate "forbidden patterns" bash scripts/check-forbidden-patterns.sh
run_gate "roadmap" bash scripts/check-roadmap.sh
run_gate "swiftformat" swiftformat . --config .swiftformat --lint
run_gate "swiftlint" swiftlint --config .swiftlint.yml --strict
run_gate "swift build" swift build

View File

@ -17,6 +17,7 @@ EMDASH=$(printf '\xe2\x80\x94')
is_enforcement_file() {
case "$1" in
.githooks/*|scripts/check-style.sh) return 0 ;;
.github/workflows/no-cursor-attribution.yml) return 0 ;;
*) return 1 ;;
esac
}
@ -33,6 +34,11 @@ PHRASES=(
"as an AI"
)
# Vendor-neutral attribution: Rule 5.1 covers every AI assistant. Vendor names in
# a list, matched against attribution prefixes, so the gate is tool-agnostic.
AI_VENDORS="Codex Copilot Gemini ChatGPT OpenAI Anthropic Cursor"
AI_PREFIXES='Co-Authored-By:|Co-authored-by:|Generated with|Generated by|with help from|Powered by'
while IFS= read -r f; do
[ -f "$f" ] || continue
if LC_ALL=C grep -qF -- "$EMDASH" "$f" 2>/dev/null; then
@ -46,6 +52,13 @@ while IFS= read -r f; do
FAIL=1
fi
done
# Vendor-neutral attribution (Rule 5.1 covers every assistant, not just Claude).
for vendor in $AI_VENDORS; do
if LC_ALL=C grep -qiE -- "($AI_PREFIXES) $vendor" "$f" 2>/dev/null; then
echo "style: forbidden attribution phrase ($vendor) in $f" >&2
FAIL=1
fi
done
fi
done < <(git ls-files)
@ -53,4 +66,9 @@ if [ "$FAIL" -ne 0 ]; then
echo "style: gate failed. Rules: docs/rules/git-discipline.md" >&2
fi
# Roadmap gate (github-discipline: the roadmap check is wired into check-style).
if ! bash scripts/check-roadmap.sh; then
FAIL=1
fi
exit "$FAIL"