mirror of
https://github.com/xerj-org/xerj.git
synced 2026-12-03 20:11:52 +08:00
Motivation PR #231's commit 15082748 and PR #219'sc16320bb(now in main) were authored with a personal e-mail address instead of xerj-org <git@xerj.org>, tripping the CLA check on #231 and putting a private address into public history. This has happened before: main also carries ten commits from early August authored with a third-party address from another project. Root cause Many concurrent agent sessions share one clone: one .git, ~95 linked worktrees, and — because extensions.worktreeConfig is unset — a single shared repo-local config. The reflogs show the effective identity flipping four times in the past week and reverting within seconds to minutes each time (e.g. 2026-08-08 12:58:44 wrong → 12:58:54 correct; 21:01:27 wrong → 21:05:01 correct, with .git/config mtime 22:24). That pattern is a transient override — an environment variable or a momentary edit of the shared config by a concurrent session — not a standing misconfiguration. An audit of every identity input on this machine confirms all are correct at rest: global user.email, the shared repo config (xerj-org <git@xerj.org>), zero per-worktree config.worktree files, no core.hooksPath, no GIT_* env in shell profiles, and no other clone of this repo. Nothing left to fix at rest; the leak can only be caught at commit time. What changed scripts/git-hooks/ (new, agent-fleet machines only — not for personal contributor checkouts): - pre-commit: resolves the exact author/committer ident git is about to use (git var GIT_AUTHOR_IDENT / GIT_COMMITTER_IDENT, which see env overrides and config alike) and refuses anything but xerj-org <git@xerj.org> or xerj-org <xerj-org@users.noreply.github.com>. - commit-msg: refuses Co-Authored-By Claude/Anthropic trailers (standing directive 2026-07-22). - install.sh: copies both into the clone's shared .git/hooks (guarded: refuses if core.hooksPath is set or a different hook already exists). Because hooks are shared, one install covers every worktree. - test.sh: scratch-repo self-test; first proves the pre-fix failure (without hooks, a leaked identity commits silently), then proves the guards (wrong config email / env author / env committer / wrong name / Claude trailer all refused; both sanctioned identities accepted). Coverage stated honestly: pre-commit fires on git commit (incl. --amend) but not on rebase/cherry-pick continuations, and --no-verify bypasses it. Both observed leaks came through plain git commit, which this intercepts. Companion git-ops (already done, no code): - 15082748 amended to1b4ee45b(identical tree/parent/message/dates, identity-only change; git diff between them is empty) and force-pushed with a pinned lease to fix/issue-210-require-if-match; the stale local branch ref was CAS-updated so a stale re-push cannot resurrect the wrong author. @cla-bot check requested on #231. -c16320bbis merged history; main is not rewritten (prevention only). Evidence - scripts/git-hooks/test.sh: 8/8 PASS. - Hooks installed live on this machine; a probe commit with the leaked identity (via GIT_AUTHOR_EMAIL/GIT_COMMITTER_EMAIL) is refused with exit 1, and this very commit passes the guard with the sanctioned identity. - PR #231 now shows author/committer xerj-org <git@xerj.org>, login xerj-org.
18 lines
645 B
Bash
Executable File
18 lines
645 B
Bash
Executable File
#!/bin/sh
|
|
# XERJ identity guard — commit-msg hook.
|
|
#
|
|
# FOR xerj-org AGENT-FLEET MACHINES ONLY.
|
|
#
|
|
# Enforces the standing repository directive (2026-07-22): commit
|
|
# messages must not carry Claude / AI co-author trailers. The history is
|
|
# authored as xerj-org, full stop.
|
|
#
|
|
# $1 is the path to the commit message file.
|
|
|
|
if grep -qiE '^[[:space:]]*Co-Authored-By:.*(claude|anthropic|noreply@anthropic\.com)' "$1"; then
|
|
echo "identity-guard: refusing commit — Co-Authored-By Claude/Anthropic trailer found." >&2
|
|
echo "identity-guard: this repository never carries AI co-author trailers (directive 2026-07-22)." >&2
|
|
exit 1
|
|
fi
|
|
exit 0
|