[misc] Load AGENTS.md every session and refuse attribution trailers (#7544)

AGENTS.md forbids attribution trailers, but a rule an agent has to go and read loses to the instruction it is handed every turn. CLAUDE.md now imports AGENTS.md so it is always in context; a commit-msg hook (via make setup-hooks) refuses the trailers at commit time; a CodeRabbit pre-merge check flags a PR whose description or commits carry them. The check reports rather than blocks, since the repository keeps CodeRabbit's request-changes workflow off; turning that on is a separate, repository-wide decision.
This commit is contained in:
Maycon Santos
2026-09-15 22:48:49 +02:00
committed by GitHub
parent 08699a9e29
commit eab510178a
5 changed files with 43 additions and 4 deletions
+10
View File
@@ -14,5 +14,15 @@ reviews:
- "!**/*.ts"
- "!**/*.js"
- "!**/*.svg"
pre_merge_checks:
custom_checks:
- name: "No attribution trailers"
mode: error
instructions: >-
Fail when the PR description or any commit message carries an
attribution trailer or footer: Co-Authored-By, Claude-Session,
Generated-By, or a "Generated with"/"Generated by" tool line.
Contributors own their contributions (AGENTS.md); ask for the
lines to be removed.
chat:
auto_reply: true
+26
View File
@@ -0,0 +1,26 @@
#!/bin/bash
# Refuses commit messages that carry attribution trailers. Contributors own
# their contributions (AGENTS.md, "No Co-Authored-By or tool-attribution
# trailers"); a trailer spreads that ownership onto a tool or a bystander.
msg_file="$1"
# Trailer keys in any casing, with any bullet or emoji in front.
trailers='^[^[:alnum:]]*(co-authored-by|claude-session|generated-by):'
# "Generated with/by" footers, including "Generated with <emoji> by".
footer='^[^[:alnum:]]*generated (with|by)( [^[:alnum:]]*by)? '
# A footer names a product, so a capitalized word must follow the phrase
# itself. Prose such as "generated by the protobuf compiler" stays legal.
tool='[Gg][Ee][Nn][Ee][Rr][Aa][Tt][Ee][Dd] ([Ww][Ii][Tt][Hh]|[Bb][Yy])( [^[:alnum:]]*[Bb][Yy])? [^[:alnum:]]*[A-Z]'
offending=$( {
grep -Ein "$trailers" "$msg_file"
grep -Ein "$footer" "$msg_file" | grep -E "$tool"
} | sort -un )
if [ -n "$offending" ]; then
echo "commit-msg: attribution trailers are not accepted in this repository:" >&2
printf '%s\n' "$offending" | sed 's/^/ /' >&2
echo "Remove them and commit again (see AGENTS.md)." >&2
exit 1
fi
+1 -1
View File
@@ -77,7 +77,7 @@ make lint # golangci-lint on files changed vs origin/main (also the p
make lint-all # full-repository lint, matches CI
make test-unit # host-safe unit tests, -tags devcert, no sudo
make test-privileged # privileged-tagged suite in a Docker container with NET_ADMIN
make setup-hooks # wire make lint into .githooks/pre-push
make setup-hooks # wire .githooks: pre-push runs make lint, commit-msg refuses attribution trailers
# Narrow runs
go test ./client/internal/dns/...
+4 -1
View File
@@ -1 +1,4 @@
See [AGENTS.md](AGENTS.md) for the agent guidelines in this repository.
The agent guidelines live in [AGENTS.md](AGENTS.md). It is imported here so
every session loads it in full rather than following a pointer.
@AGENTS.md
+2 -2
View File
@@ -23,8 +23,8 @@ lint-install: $(GOLANGCI_LINT)
# Setup git hooks for all developers
setup-hooks:
@git config core.hooksPath .githooks
@chmod +x .githooks/pre-push
@echo "✅ Git hooks configured! Pre-push will now run 'make lint'"
@chmod +x .githooks/pre-push .githooks/commit-msg
@echo "✅ Git hooks configured! Pre-push runs 'make lint'; commit-msg refuses attribution trailers"
# Host-safe unit tests: excludes the privileged-tagged tests (root / system-mutating).
# Runs as a normal user with no sudo and leaves host networking untouched.