Skip to content

feat(spawn): disable commit signing per task worktree - #1

Merged
7hoenix merged 3 commits into
mainfrom
fm/fm-unsign-g3
Jul 12, 2026
Merged

7hoenix merged 3 commits into
mainfrom
fm/fm-unsign-g3

Conversation

@7hoenix

@7hoenix 7hoenix commented Jul 12, 2026

Copy link
Copy Markdown
Owner

Intent

Make bin/fm-spawn.sh disable git commit signing automatically for each task worktree it acquires, so autonomous crewmates never block on an interactive commit signer (e.g. a GUI GPG / 1Password agent that needs a click). Unsigned autonomous commits are standing policy. Requirements the reviewer would not see from the diff alone: (1) The override MUST be scoped to the task worktree only - the primary firstmate checkout, the captain's own repos, and sibling worktrees of the pooled clone must keep their normal signing. I chose git's per-worktree config namespace (git config extensions.worktreeConfig true on the shared pooled repo, then git config --worktree commit.gpgsign false / tag.gpgsign false in the task worktree) over an env-var approach, because it is persistent, observable via 'git config', and is what makes the acceptance test ('worktree resolves commit.gpgsign=false while pooled clone untouched') meaningful. I verified empirically that enabling extensions.worktreeConfig on firstmate's actual pooled clone is safe: the core.bare/core.worktree footgun does not apply (core.bare=false is harmless, core.worktree unset, git migrates/duplicates nothing), the primary keeps signing, and on a repositoryformatversion=0 repo an older git merely ignores the extension so signing stays on (degrades to today's behavior, never corrupts). Ordering matters and is deliberate: the extension is enabled first, else 'git config --worktree' silently leaks to the shared config. (2) Both commit.gpgsign and tag.gpgsign are covered. (3) Applied to ship, scout, AND secondmate worktrees - secondmate homes are deliberately included because they are worktrees of the firstmate repo that an autonomous agent commits shared material in, so the same block would hit them. (4) No opt-out knob by deliberate choice: an autonomous session can never answer a GUI signer and unsigned autonomous commits are standing policy, so per the repo's coding guidelines the script/lib header owns this rather than a config knob or docs/configuration.md. The logic lives in a new sourceable lib bin/fm-sign-lib.sh (matching the fm-ff-lib.sh / fm-config-inherit-lib.sh idiom) called once from fm-spawn after the worktree is finalized and validated for every kind; it is best-effort (warns, does not abort a live spawn, on failure). The colocated test tests/fm-sign-lib.test.sh reproduces the real block with an unavailable signer and asserts worktree gpgsign=false with the pooled clone untouched, plus idempotency and non-worktree rejection. The test also contains a one-line mkdir -p on the tmp root to work around a pre-existing harness quirk where fm_test_tmproot's cleanup trap fires in the command-substitution subshell under bash 5.3.

What Changed

  • Added bin/fm-sign-lib.sh, a sourceable library that scopes commit signing off for a single task worktree: it enables extensions.worktreeConfig on the shared pooled repo, then sets commit.gpgsign and tag.gpgsign to false via git config --worktree, leaving the pooled clone and sibling worktrees untouched. It is idempotent and rejects non-worktree targets.
  • Wired bin/fm-spawn.sh to call disable_worktree_commit_signing once after the worktree is finalized and validated, for ship, scout, and secondmate spawns, as best-effort (warns without aborting the spawn on failure) so autonomous agents never block on an interactive commit signer.
  • Tightened the herdr backend's bare-prompt composer-state regex to a byte-exact match, and synced docs/scripts.md and docs/configuration.md to document the new signing library and the regex change.

Risk Assessment

✅ Low: A small, well-bounded, well-documented change with a dedicated colocated test; the mechanism is correctly scoped to the task worktree, ordered before agent launch, and fails safe with a warning.

Testing

The configured baseline suite already passed on the runner; here I focused on the signing change. tests/fm-sign-lib.test.sh passes (5/5) and reproduces the real interactive-signer block, and a hand-run end-to-end demo confirms the full intent: after the disable the task worktree resolves commit.gpgsign/tag.gpgsign=false and commits under an unavailable signer, the override lives in the worktree's own config.worktree (zero gpgsign entries in shared config), and the pooled clone plus sibling worktree keep signing=true and still block. I also confirmed fm-spawn calls the lib after $WT is finalized for ship, scout, and secondmate kinds, and the adjacent spawn/herdr/teardown suites pass. The only suite failure I observed (fm-session-start.test.sh "pi supervision block") is an environment artifact of running inside a Claude Code session — fm-harness.sh short-circuits on CLAUDECODE=1 — and is unrelated to this diff (session-start machinery is untouched); re-running with CLAUDECODE unset passes 16/16. No product issues found; worktree left clean.

Evidence: Commit-signing scope demo (end-to-end CLI transcript)

>>> BEFORE: autonomous commit in task worktree BLOCKS (signer unavailable) commit FAILED as expected -> an unattended crewmate would hang here forever >>> disable_worktree_commit_signing <task-worktree> returned 0 task worktree commit.gpgsign = false tag.gpgsign = false pooled clone commit.gpgsign = true tag.gpgsign = true (UNCHANGED) sibling worktree commit.gpgsign = true tag.gpgsign = true (UNCHANGED) per-worktree config.worktree present: yes; shared .git/config gpgsign: 0 >>> AFTER: task-worktree commit SUCCEEDED; pool commit still BLOCKS

###############################################################################
# fm-spawn commit-signing scope demo
# Global config forces commit.gpgsign=true + tag.gpgsign=true with a signer
# binary that does not exist (an interactive GUI signer an agent can't answer).
###############################################################################

>>> BEFORE: an autonomous commit in the task worktree BLOCKS (signer unavailable)
fatal: cannot exec '/var/folders/jn/8w1m9pnx6p16d2kkzjcbwnmr0000gn/T/tmp.P7Kbu3xXkJ/nonexistent-gui-signer': No such file or directory
error: gpg failed to sign the data:
(no gpg output)
fatal: failed to write commit object
    commit FAILED as expected -> an unattended crewmate would hang here forever

>>> fm-spawn runs: disable_worktree_commit_signing <task-worktree>
    returned 0 (success)

>>> Resolved config AFTER disable (git config, effective values):
    task worktree    commit.gpgsign = false   tag.gpgsign = false
    pooled clone     commit.gpgsign = true   tag.gpgsign = true   (UNCHANGED)
    sibling worktree commit.gpgsign = true   tag.gpgsign = true   (UNCHANGED)

>>> Where the override lives (scoped, not in shared config):
    per-worktree file present : yes
    shared .git/config gpgsign: 0 occurrences

>>> AFTER: task worktree commits cleanly; primary/pool still refuses to sign
    task-worktree commit SUCCEEDED  -> autonomous crewmate is unblocked
    pool commit still BLOCKS        -> captain's checkout keeps normal signing
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (1h9m41s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-sign-lib.sh:50 - disable_worktree_commit_signing writes extensions.worktreeConfig to the SHARED pooled repo config (git config, which acquires .git/config.lock). If firstmate spawns two crewmates against the same project pooled clone as parallel tool calls, both may hit that lock in the brief write window; the loser gets a git-config failure, the function returns non-zero, and signing is NOT disabled for that worktree - so that autonomous crewmate can still block on an interactive signer. This is by-design best-effort (it warns loudly) and realistically rare (batch dispatch is sequential, and the collision window is tiny relative to the treehouse work each spawn does first), but the failure mode is worth noting since the whole point is to prevent an unattended block.
🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 tests failed with exit code 1
  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"

🔧 Fix: fix(herdr): byte-exact bare-prompt regex for composer state
✅ Re-checked - no issues remain.

  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • bash tests/fm-sign-lib.test.sh — 5/5 ok (baseline block reproduces, scoped disable, disabled worktree commits while primary blocks, idempotent, rejects non-worktree)
  • End-to-end CLI demo sourcing bin/fm-sign-lib.sh against a pooled repo + task/sibling worktrees with a forced-signing global config pointing at a nonexistent signer; captured to signing-scope-demo.txt
  • Verified fm-spawn.sh wiring: disable_worktree_commit_signing &#34;$WT&#34; at line 856 runs after $WT is finalized for secondmate (606), ship/scout (834) and after validate_spawn_worktree
  • Ran adjacent suites covering the touched files: bash tests/fm-spawn-batch.test.sh, tests/fm-spawn-dispatch-profile.test.sh, tests/fm-backend-herdr.test.sh, tests/fm-composer-ghost.test.sh, tests/fm-tangle-guard.test.sh, tests/fm-teardown.test.sh — all ok
  • Isolated bash tests/fm-session-start.test.sh failed only due to CLAUDECODE=1 leaking from the Claude Code session; env -u CLAUDECODE bash tests/fm-session-start.test.sh passes 16/16 (exit 0)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

7hoenix added 3 commits July 11, 2026 18:54
Autonomous crewmates inherit the operator's global git config; a
commit.gpgsign=true backed by an interactive signer (e.g. a GUI GPG or
1Password agent) blocks every autonomous commit. Unsigned autonomous
commits are standing policy, so fm-spawn now disables commit and tag
signing for each worktree it hands off.

New fm-sign-lib.sh scopes the override to the one worktree via git's
per-worktree config namespace (extensions.worktreeConfig +
git config --worktree), so the primary checkout, sibling pooled
worktrees, and the captain's own repos keep their normal signing.
Applied to ship, scout, and secondmate worktrees. Colocated test
reproduces the block with an unavailable signer and asserts the
worktree resolves gpgsign=false while the pooled clone stays untouched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant