You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by po...@apache.org on 2026/09/14 12:49:44 UTC

(magpie) 01/01: docs(agents): gate signing commits on a hardware-key cache probe

This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch docs/hardware-key-signing-gate
in repository https://gitbox.apache.org/repos/asf/magpie.git

commit 6de80f805324f34e47df006b02440da84b0dc8e5
Author: Jarek Potiuk <ja...@potiuk.com>
AuthorDate: Mon Sep 14 14:49:18 2026 +0200

    docs(agents): gate signing commits on a hardware-key cache probe
    
    An agent that runs `git commit` with `commit.gpgsign` true and a
    token-backed signing key blocks on a pinentry prompt it cannot
    see: a GUI pinentry pops a dialog on the operator's desktop that
    nobody is watching, a TTY pinentry writes to the terminal the
    tool call owns. The call sits until `gpg: signing failed:
    Timeout` and no commit is created — a silent-looking failure that
    burns a couple of minutes per attempt and leaves the tree
    mid-operation. Hit live in this repo while amending a commit.
    
    AGENTS.md grows the rule and the probe: resolve the signing
    subkey's keygrip, ask gpg-agent for its keyinfo, and read type
    (T = token) and cached (1 = warm, - = cold). Cold means the
    commit will prompt, so surface a dialogue naming the key or hand
    the operator the command; warm means commit without interrupting
    them. Re-probe rather than assume warmth persists — the default
    idle TTL is 600s. The rule covers rebase, cherry-pick, tag -s and
    --amend, which produce signed objects the same way.
    
    The three skills that run `git commit` themselves — issue
    fix-workflow, repo-health audit-finding-fix, and setup
    shared-config-sync — reference it from their commit steps. They
    already confirmed the commit message; they said nothing about the
    commit being able to hang. setup override-upstream is untouched:
    it prints its commit for the operator to run, so pinentry already
    reaches a terminal.
    
    Release-artefact signing needed no change. release-rc-cut has a
    stronger rule already — Golden rule 2, the agent never invokes
    gpg at all, it emits the commands for the release manager.
    
    Generated-by: Claude Opus 5
    Claude-Session: https://claude.ai/code/session_01VAJ5GbXnv4LWMfDdvDNJKE
---
 AGENTS.md                                          | 33 ++++++++++++++++++++++
 plugins/magpie-issue/skills/fix-workflow/SKILL.md  | 11 ++++++++
 .../skills/audit-finding-fix/SKILL.md              | 11 ++++++++
 .../skills/shared-config-sync/SKILL.md             |  6 ++++
 4 files changed, 61 insertions(+)

diff --git a/AGENTS.md b/AGENTS.md
index d145f76f..8c4465ed 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -548,6 +548,39 @@ to a home-dir path and update the tool to read from there.
   ships no new functionality, lint, docs-only edits) are exempt.
 - Keep the commit message focused on the user-visible change, not the mechanics of how the edit
   was made.
+- **Never blind-run a signing commit against a hardware key.** When
+  `commit.gpgsign` is true and the signing key lives on a token (YubiKey,
+  Nitrokey, any OpenPGP card), `git commit` blocks on a pinentry prompt.
+  A GUI pinentry (`pinentry-gnome3`, `pinentry-qt`) pops a dialog on the
+  operator's desktop that the agent cannot see and the operator is not
+  watching; a TTY pinentry tries to write to the terminal the agent's tool
+  call owns. Either way the call sits until `gpg: signing failed: Timeout`
+  and **no commit is created** — a silent-looking failure that costs a
+  couple of minutes per attempt and leaves the tree mid-operation.
+
+  Probe the agent's cache *before* committing. `cached=1` means the
+  commit will not prompt; `cached=-` means it will:
+
+  ```bash
+  grip=$(gpg --list-secret-keys --with-colons --with-keygrip \
+           "$(git config --get user.signingkey)" \
+         | awk -F: '/^ssb/{s=($12 ~ /s/)} /^grp/{if(s){print $10; exit}}')
+  gpg-connect-agent "keyinfo $grip" /bye \
+    | awk '$1=="S"{print "type="$4" cached="$7}'
+  ```
+
+  `type=T` is a token-backed key; `type=D` is an on-disk key, which
+  prompts for a passphrase rather than a touch but blocks the same way.
+  On `cached=-`, surface a dialogue naming the key and telling the
+  operator to expect the prompt, or hand them the `git commit` line to run
+  in their own terminal — do not run it and hope. On `cached=1`, commit
+  without interrupting them. Re-probe rather than assuming warmth
+  persists: the default `default-cache-ttl` is 600s idle.
+
+  The same applies to any `git rebase`, `git cherry-pick`, `git tag -s`, or
+  `--amend` that produces a signed object. Release-artefact signing is
+  already covered by a stronger rule — `release-rc-cut` never invokes `gpg`
+  at all, it emits the commands for the release manager to run.
 
 ## Labeling issues, PRs, tools, and documentation
 
diff --git a/plugins/magpie-issue/skills/fix-workflow/SKILL.md b/plugins/magpie-issue/skills/fix-workflow/SKILL.md
index 49c8116a..f235fe2a 100644
--- a/plugins/magpie-issue/skills/fix-workflow/SKILL.md
+++ b/plugins/magpie-issue/skills/fix-workflow/SKILL.md
@@ -511,6 +511,17 @@ shapes:
 Show the commit message to the user; ask for confirmation before
 running `git commit`.
 
+**Signing pre-flight.** If `commit.gpgsign` is true, probe the
+gpg-agent cache before running `git commit` — a token-backed
+signing key with a cold cache blocks on a pinentry prompt the
+agent cannot see, and the commit dies with
+`gpg: signing failed: Timeout` after a long stall. On a cold
+cache, surface a dialogue telling the user to expect the prompt
+(or hand them the command to run in their own terminal); on a
+warm cache, commit without interrupting them. The probe and the
+rationale are in
+[`AGENTS.md` → *Commit and PR conventions*](../../../../AGENTS.md#commit-and-pr-conventions).
+
 ---
 
 ## Step 8 — Hand-back artefact
diff --git a/plugins/magpie-repo-health/skills/audit-finding-fix/SKILL.md b/plugins/magpie-repo-health/skills/audit-finding-fix/SKILL.md
index cfb7c600..55bab812 100644
--- a/plugins/magpie-repo-health/skills/audit-finding-fix/SKILL.md
+++ b/plugins/magpie-repo-health/skills/audit-finding-fix/SKILL.md
@@ -466,6 +466,17 @@ Write the commit message per the project's convention:
 Show the commit message to the user; ask for confirmation before
 running `git commit`.
 
+**Signing pre-flight.** If `commit.gpgsign` is true, probe the
+gpg-agent cache before running `git commit` — a token-backed
+signing key with a cold cache blocks on a pinentry prompt the
+agent cannot see, and the commit dies with
+`gpg: signing failed: Timeout` after a long stall. On a cold
+cache, surface a dialogue telling the user to expect the prompt
+(or hand them the command to run in their own terminal); on a
+warm cache, commit without interrupting them. The probe and the
+rationale are in
+[`AGENTS.md` → *Commit and PR conventions*](../../../../AGENTS.md#commit-and-pr-conventions).
+
 Return ONLY valid JSON with this structure:
 
 ```json
diff --git a/plugins/magpie-setup/skills/shared-config-sync/SKILL.md b/plugins/magpie-setup/skills/shared-config-sync/SKILL.md
index de1c7f85..611abef7 100644
--- a/plugins/magpie-setup/skills/shared-config-sync/SKILL.md
+++ b/plugins/magpie-setup/skills/shared-config-sync/SKILL.md
@@ -328,6 +328,12 @@ contains — on a brand-new scaffold there may be nothing under
      per AGENTS.md — the actual agent and model you are
      running as, not a hardcoded value.
 
+   Probe the gpg-agent cache first when `commit.gpgsign` is
+   true: a token-backed key with a cold cache stalls this
+   commit until `gpg: signing failed: Timeout`. Surface a
+   dialogue, or hand the user the command — see
+   [`AGENTS.md` → *Commit and PR conventions*](../../../../AGENTS.md#commit-and-pr-conventions).
+
 6. **Push.** `git push` to the upstream branch. No `--force`.
    If push is rejected (non-fast-forward) it means another
    machine pushed concurrently after our `git fetch` in step 2;