Repository navigation
fix(bin): strip AI co-author trailers from fleet-launched commits - #5695
Conversation
Cursor and other non-Claude runtimes append the trailer after the typed message. A per-task commit-msg hook removes it and leaves human co-authors and the author identity untouched.
… test-only: 4 test files change, no product code. **Cause.** `fm-spawn.sh` now installs the AI-trailer strip hooks for every spawn, secondmates included. The installer refuses a worktree that is not a git repository, and the PR deliberately keeps that fail-closed rule because real secondmate homes are firstmate clones. Four test fixtures still gave secondmates a plain directory as their home, so each spawn failed with "not a git worktree ... could not install the AI-trailer strip hooks": - serial 5: `tests/fm-backlog-atomicity.test.sh` ("secondmate spawn failed"). - serial 8: `tests/fm-secondmate-harness.test.sh` ("split: no meta written"). - Herdr: `tests/fm-backend-herdr-launcher-workspace-e2e.test.sh` and `tests/fm-backend-herdr-workspace-per-home-e2e.test.sh`. **Rule that must hold.** Every home a test spawns as a secondmate must be a git worktree. I checked the other places in the changed area: the only secondmate spawns in these tests are the ones listed. The earlier rounds already fixed the other fixtures (`fm-secondmate-liveness`, `fm-secondmate-safety`) the same way. **Fix.** - Each of those four secondmate homes now gets the same `.gitignore` plus `git init -q -b main` that the liveness and safety tests already use. - The two Herdr tests clean up with their own plain `rm -rf "$TMP_ROOT"`, not the shared `tests/lib.sh` helper. Because the installer leaves each `state/<id>.git-hooks` directory read-only, that cleanup printed "Permission denied" and left the directories behind. Both cleanups now restore the owner's write bit on every directory before removing (`find ... -exec chmod u+rwx`), which is what `fm_test_remove_tree` in `tests/lib.sh` does. **Verification.** - `tests/fm-secondmate-harness.test.sh` passes. - `tests/fm-backlog-atomicity.test.sh` passes (99 ok, exit 0). - shellcheck is clean on all four files. - I could not run the two real-Herdr tests locally: the Herdr lab on this host refuses to start because it needs exactly one running default session, and I did not change the host's Herdr state to get around that. Instead I checked their two changed steps directly: the installer succeeds on a home set up the new way, and the new cleanup removes the read-only hooks directory completely. Those two tests will only be proven on CI
|
Speaking as Kun's firstmate: Verdict: Diff reviewed ( contract-class: VISION: One captain / honesty — aligns (published commits stay clean). Authority explicit — aligns (enforces existing attribution-off policy; no new autonomy). Scripts own mechanics — aligns. Restart — aligns (per-task hooks dir cleaned on teardown). Delegation/spine — aligns. Vendor — aligns (runtime-agnostic strip; Claude defense-in-depth). Scope — aligns (spawn/commit hygiene, not workshop). Attestation: MATCH |
|
Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this. |
…nchenguid#5695) * fix(bin): strip AI co-author trailers from fleet-launched commits Cursor and other non-Claude runtimes append the trailer after the typed message. A per-task commit-msg hook removes it and leaves human co-authors and the author identity untouched. * no-mistakes(review): Export pane hooksPath override and drop generated-with stripping * no-mistakes(ci): This PR caused all three CI failures, and the fix is test-only: 4 test files change, no product code. **Cause.** `fm-spawn.sh` now installs the AI-trailer strip hooks for every spawn, secondmates included. The installer refuses a worktree that is not a git repository, and the PR deliberately keeps that fail-closed rule because real secondmate homes are firstmate clones. Four test fixtures still gave secondmates a plain directory as their home, so each spawn failed with "not a git worktree ... could not install the AI-trailer strip hooks": - serial 5: `tests/fm-backlog-atomicity.test.sh` ("secondmate spawn failed"). - serial 8: `tests/fm-secondmate-harness.test.sh` ("split: no meta written"). - Herdr: `tests/fm-backend-herdr-launcher-workspace-e2e.test.sh` and `tests/fm-backend-herdr-workspace-per-home-e2e.test.sh`. **Rule that must hold.** Every home a test spawns as a secondmate must be a git worktree. I checked the other places in the changed area: the only secondmate spawns in these tests are the ones listed. The earlier rounds already fixed the other fixtures (`fm-secondmate-liveness`, `fm-secondmate-safety`) the same way. **Fix.** - Each of those four secondmate homes now gets the same `.gitignore` plus `git init -q -b main` that the liveness and safety tests already use. - The two Herdr tests clean up with their own plain `rm -rf "$TMP_ROOT"`, not the shared `tests/lib.sh` helper. Because the installer leaves each `state/<id>.git-hooks` directory read-only, that cleanup printed "Permission denied" and left the directories behind. Both cleanups now restore the owner's write bit on every directory before removing (`find ... -exec chmod u+rwx`), which is what `fm_test_remove_tree` in `tests/lib.sh` does. **Verification.** - `tests/fm-secondmate-harness.test.sh` passes. - `tests/fm-backlog-atomicity.test.sh` passes (99 ok, exit 0). - shellcheck is clean on all four files. - I could not run the two real-Herdr tests locally: the Herdr lab on this host refuses to start because it needs exactly one running default session, and I did not change the host's Herdr state to get around that. Instead I checked their two changed steps directly: the installer succeeds on a home set up the new way, and the new cleanup removes the read-only hooks directory completely. Those two tests will only be proven on CI
…nchenguid#5695) * fix(bin): strip AI co-author trailers from fleet-launched commits Cursor and other non-Claude runtimes append the trailer after the typed message. A per-task commit-msg hook removes it and leaves human co-authors and the author identity untouched. * no-mistakes(review): Export pane hooksPath override and drop generated-with stripping * no-mistakes(ci): This PR caused all three CI failures, and the fix is test-only: 4 test files change, no product code. **Cause.** `fm-spawn.sh` now installs the AI-trailer strip hooks for every spawn, secondmates included. The installer refuses a worktree that is not a git repository, and the PR deliberately keeps that fail-closed rule because real secondmate homes are firstmate clones. Four test fixtures still gave secondmates a plain directory as their home, so each spawn failed with "not a git worktree ... could not install the AI-trailer strip hooks": - serial 5: `tests/fm-backlog-atomicity.test.sh` ("secondmate spawn failed"). - serial 8: `tests/fm-secondmate-harness.test.sh` ("split: no meta written"). - Herdr: `tests/fm-backend-herdr-launcher-workspace-e2e.test.sh` and `tests/fm-backend-herdr-workspace-per-home-e2e.test.sh`. **Rule that must hold.** Every home a test spawns as a secondmate must be a git worktree. I checked the other places in the changed area: the only secondmate spawns in these tests are the ones listed. The earlier rounds already fixed the other fixtures (`fm-secondmate-liveness`, `fm-secondmate-safety`) the same way. **Fix.** - Each of those four secondmate homes now gets the same `.gitignore` plus `git init -q -b main` that the liveness and safety tests already use. - The two Herdr tests clean up with their own plain `rm -rf "$TMP_ROOT"`, not the shared `tests/lib.sh` helper. Because the installer leaves each `state/<id>.git-hooks` directory read-only, that cleanup printed "Permission denied" and left the directories behind. Both cleanups now restore the owner's write bit on every directory before removing (`find ... -exec chmod u+rwx`), which is what `fm_test_remove_tree` in `tests/lib.sh` does. **Verification.** - `tests/fm-secondmate-harness.test.sh` passes. - `tests/fm-backlog-atomicity.test.sh` passes (99 ok, exit 0). - shellcheck is clean on all four files. - I could not run the two real-Herdr tests locally: the Herdr lab on this host refuses to start because it needs exactly one running default session, and I did not change the host's Herdr state to get around that. Instead I checked their two changed steps directly: the installer succeeds on a home set up the new way, and the new cleanup removes the read-only hooks directory completely. Those two tests will only be proven on CI
Intent
Fixes #5665.
Implement ready-for-pr issue #5665: worker runtimes other than Claude Code can add an AI Co-authored-by trailer to the commits they make, and nothing in the launch path removes it. Commits made inside any worker pane that firstmate launches should carry no AI co-author trailer, whatever the runtime, while human co-authors and the author identity are left untouched.
What Changed
bin/fm-git-strip-ai-trailers.sh.As a
commit-msghook, it removesCo-authored-bytrailers that match known AI product names (Cursor, Claude, Copilot, Codex, ChatGPT, Gemini, Grok, OpenAI) or bot addresses seen in practice.Human co-authors and the author identity are left untouched.
Its
installmode builds a read-only per-task hooks directory.Every other client-side hook in that directory is a wrapper that runs the hook of the same name from the repository git is actually running in, so project hooks such as husky still run.
fm-spawn.shnow installsstate/<id>.git-hooksfor every launch kind, including secondmates, and fails closed if the install fails.The pane gets that directory as
core.hooksPaththroughGIT_CONFIG_COUNT/GIT_CONFIG_KEY_0/GIT_CONFIG_VALUE_0, so the project's own git config is not rewritten.A failed spawn removes the directory unless the launched agent's pane may still be open.
fm-teardown.shrestores the owner write bit on the read-only hooks directory and then removes it, both for a task and for a secondmate home's children.The
tests/lib.shcleanup does the same for test fixtures.Added
tests/fm-git-strip-ai-trailers.test.shand updated the existing spawn tests for the new launch prefix.Documented the mechanism in
docs/configuration.md,docs/scripts.md,AGENTS.md, and the Cursor harness reference.Risk Assessment
Testing
Everything ran in a disposable lab home with its own tmux socket. I spawned three real workers with the real fm-spawn.sh: two raw launches, one of them chained, and one real cursor-agent with attribution on. For each, I checked the commit object git wrote. The AI trailers were gone in all three, while human co-authors, author identity and the project's husky hooks were untouched. A control run of Cursor outside a fleet pane reproduced the original trailer. fm-teardown.sh removed the strip directories. I also ran the focused strip test file. All scenarios passed. Transcripts are in the evidence dir, and I removed the lab, its tmux server and the treehouse pool it created.
git commit --trailer "Co-authored-by: Cursor <[email protected]>"; the commit in lab-transcript.md has no trailer. The control run outside a pane kept it…cd src && agent) still gets the strip on its commitgit config --show-origin core.hooksPathis still .husky in .git/configEvidence: Live lab transcript: spawn logs, commit objects, control repro, teardown
Source: Live lab transcript: spawn logs, commit objects, control repro, teardown
Evidence: Real cursor-agent pane capture showing it ran git commit --trailer Co-authored-by: Cursor
Source: Real cursor-agent pane capture showing it ran git commit --trailer Co-authored-by: Cursor
Evidence: Fleet-pane Cursor commit vs control
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-spawn.sh:4921- The core.hooksPath override is added in front of the launch command as a one-command prefix (GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.hooksPath GIT_CONFIG_VALUE_0=... $LAUNCH). A shell prefix like this only applies to the first simple command. For a raw launch that chains several steps (for examplecd sub && my-agentorsetup; my-agent), the override reaches onlycd/setup. The agent then commits without the strip hook, and its AI trailer lands in the commit. The code a few lines below already relies on this rule: the compact-adviser switch is anexportprecisely so it 'carries the value across an entire compound raw launch expression' (fm-spawn.sh:4924-4926). The raw-launch escape hatch is how unverified runtimes are launched, and the intent requires the strip 'whatever the runtime'. Fix: emitexport GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=core.hooksPath GIT_CONFIG_VALUE_0=<dir>;next to the COMPACT_ADVISER_DISABLE export. That scopes the override to the worker pane shell, not the spawn process. Then update the expected launch strings built by ai_trailer_hooks_prefix in the spawn tests.bin/fm-git-strip-ai-trailers.sh:120- Simplification: the matcher also deletes lines that start with 'Generated with ...claude...' and 'Generated-by: ...claude/cursor...'. The intent asks only that commits carry no AI Co-authored-by trailer. These lines go beyond that, and Claude launches already turn them off through the attribution settings. Recommended remedy: remove this generated-with branch, and the test_claude_generated_with_line_is_stripped and test_prose_mentioning_generated_with_survives cases that exist only for it. If the author wants this broader attribution cleanup, confirm it as intended scope.🔧 Fix applied.
2 issues (1 warning, 1 info) still open:
bin/fm-git-strip-ai-trailers.sh:120- Simplification: the matcher also deletes lines that start with 'Generated with ...claude...' and 'Generated-by: ...claude/cursor...'. The intent asks only that commits carry no AI Co-authored-by trailer. These lines go beyond that, and Claude launches already turn them off through the attribution settings. Recommended remedy: remove this generated-with branch, and the test_claude_generated_with_line_is_stripped and test_prose_mentioning_generated_with_survives cases that exist only for it. If the author wants this broader attribution cleanup, confirm it as intended scope.bin/fm-git-strip-ai-trailers.sh:19- The usage header still says the caller 'prefixes the pane with GIT_CONFIG_COUNT / GIT_CONFIG_KEY_0 / GIT_CONFIG_VALUE_0'. The round-1 fix changed fm-spawn.sh:4922 to anexport ...;statement, so this header now describes a one-command prefix that no longer exists. A reader would believe the chained-launch gap is still present. Fix: change the wording to 'exports GIT_CONFIG_COUNT / GIT_CONFIG_KEY_0 / GIT_CONFIG_VALUE_0 in the pane command'.✅ **Test** - passed
✅ No issues found.
git commit --trailer "Co-authored-by: Cursor <[email protected]>"; the commit in lab-transcript.md has no trailer. The control run outside a pane kept it…cd src && agent) still gets the strip on its commitgit config --show-origin core.hooksPathis still .husky in .git/configbin/fm-lab-home.sh create $LABplustmux -L fm-lab new-sessionprimary pane, with a real project repo that uses core.hooksPath=.husky (commit-msg and pre-commit hooks)bin/fm-spawn.sh s1 $LAB/projects/app --scout 'bash $LAB/agent.sh plain'(raw launch; the agent commits a message carrying Cursor/Claude/Copilot trailers and two human co-authors)bin/fm-spawn.sh s2 $LAB/projects/app --scout 'cd src && bash $LAB/agent.sh chained'(chained raw launch)Control: realcursor-agent -p --forcecommit in the treehouse worktree outside a fleet pane (bug reproduction)bin/fm-spawn.sh s3 $LAB/projects/app --scout --harness cursor, where the brief asks Cursor to commit a file; inspected the commit object and captured the panebin/fm-teardown.sh s1|s2|s3 --force, then checked that the state/*.git-hooks dirs are gonebash tests/fm-git-strip-ai-trailers.test.sh✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.