Repository navigation
fix(agent-isolation): show the touch overlay on macOS and for ssh-signed commits - #1288
Merged
Merged
Conversation
…ned commits The watcher only knew gpg, and its window was GTK or zenity — a Mac has neither, and a `gpg.format=ssh` commit signs via `ssh-keygen -Y sign` over gpg-agent's socket without starting gpg at all. Either way the key waited for a touch with nothing on screen. - watch `ssh-keygen` alongside `gpg`/`gpg2` (exact-name match kept) - add a Tk overlay window for macOS: main display, borderless rather than native fullscreen so the terminal is not pulled to another Space - probe for a python that can actually start Tk, not just import tkinter (uv/pyenv/Homebrew pythons commonly lack the Tcl/Tk framework) - fall back to perl's POSIX::setsid where setsid(1) is missing, keeping the watcher a session leader so disarm's group kill still closes the window - arm/disarm always exit 0: a hook verdict must never block a commit over missing plumbing Generated-by: Claude Fable 5.1
…ront of the keyboard Three things kept the window off the screen at the moment the key was actually waiting: - Tcl finds init.tcl relative to the executable it was started as and does not follow symlinks, so the `python3` symlink uv or pyenv puts on PATH fails "Tcl wasn't installed properly" while the interpreter behind it works. The probe then fell through to the Command Line Tools python, whose Apple Tk 8.5 starts and draws nothing for the borderless window. Probe and report each candidate by its resolved path, and insist on Tk 8.6. - The watcher took the first signing process ending as the end of the watch. A pre-commit hook that runs this tool's own test suite starts a process named ssh-keygen for half a second, so the watcher was gone before git signed; a rebase signing several commits lost all but the first the same way. The watcher now lives until disarm, hiding the window between signatures — and actually exits on disarm's SIGTERM, which the old trap swallowed. - A touch that lands before the key asks for one fires the OTP slot and types into whatever is in front. The window now activates its process and takes the keyboard while it is up, so those keystrokes land in the overlay instead. Generated-by: Claude Fable 5.1
…h overlay and the ssh signing key With gpg.format=ssh the sandbox's ~/.ssh read deny stops git before the key is ever asked for a touch, and nothing in the isolated setup said so. Now it does, at every layer: - sandbox-troubleshooting.md gains a catalog entry for the failure (symptom verbatim from a sandboxed run, one-file allowRead fix), and the settings template carries the entry - the SSH-agent entry claimed a read grant on the socket was enough on both platforms; on macOS connect(2) needs sandbox.network.allowUnixSockets as well — symptom, fix and template entry added - setup-isolated-setup-verify: check 10 — overlay hooks wired, scripts matching the framework copies, toolkit probe run outside the sandbox by the user, signing key readable from sandboxed Bash - setup-isolated-setup-doctor: probe 5 — signing-key readability, in the catalog's lock-step shape; probe 1 names the macOS socket case - setup-isolated-setup-update: the overlay scripts join the drift list - evals: both suites were extracting a heading the skills no longer had; headings and output specs brought in line, one new case each - the overlay tests skip instead of erroring where the sandbox hides ps, so the pre-commit run passes inside it - the Tk probe lists the usual interpreter homes by absolute path: the hook runs with the harness's environment, not the shell's PATH - the command matcher accepts a shell separator after the subcommand (`git commit;` signs just as much as `git commit -m`) - a marker file turns the watcher's log on where no variable can be set — the hook's environment — and the log then carries a trace, the window's own output, and the environment it drew from Generated-by: Claude Fable 5.1
…ndbox The agent-socket grant makes signing work; a push over ssh still gets no DNS and no TCP from the sandbox, whose network is its HTTP proxy alone. Say so next to the socket fix, with the symptom and the two ways out (push from the terminal, or an https remote). Generated-by: Claude Fable 5.1
arm opened the log with a truncating, non-append redirection for the watcher while the window and its spawner appended to the same file, so the watcher's trace overwrote their lines at its own offset — the environment line the log exists to capture never survived. Truncate once, then have everyone append. Generated-by: Claude Fable 5.1
Merged
15 of 23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
gpg-touch-overlay.shonly watched forgpg, and its window was GTK with a zenity fallback. A Mac has neither, and agpg.format=sshcommit signs viassh-keygen -Y signover gpg-agent's socket without ever starting gpg — so on macOS, and for ssh-signed commits anywhere, the key waited for a touch with nothing on screen.ssh-keygenalongsidegpg/gpg2(exact-name match kept), and macOS gets its own Tk window (gpg-touch-overlay-window-macos.py): main display only, borderless rather than native fullscreen so macOS does not switch Spaces out from under the terminal.setsid(1); the watcher falls back to perl'sPOSIX::setsidso it still leads its own session anddisarm's single group kill closes the window.arm/disarmalways exit 0: aPreToolUseverdict must never block a commit over missing plumbing. The internal probes keep their real status for the tests.Dogfooding this on the branch itself surfaced three more things that kept the window off the screen at the moment the key was actually waiting (second commit):
init.tclrelative to the executable it was started as and does not follow symlinks, so thepython3symlink uv or pyenv puts on PATH fails with "Tcl wasn't installed properly" while the interpreter behind it works. The probe then fell through to the Command Line Tools python, whose Apple Tk 8.5 starts and draws nothing for a borderless translucent window (or hangs setting it up)._tk_pythonnow probes and reports each candidate by its resolved path and insists on Tk ≥ 8.6.ssh-keygenfor half a second, so the watcher was gone before git signed; a rebase signing several commits lost all but the first the same way. It now lives untildisarm, hiding the window between signatures — and actually exits ondisarm's SIGTERM, which the oldtrapswallowed (it ranhide_overlayand kept looping).Dogfooding the sandboxed path (third and fourth commits) turned up what the isolated setup got wrong for
gpg.format=ssh, now covered at every layer:sandbox-troubleshooting.md: a catalog entry for the signing-key read deny (symptom verbatim from a sandboxed run, one-fileallowReadfix); the SSH-agent entry claimed a read grant on the socket was enough on both platforms — on macOSconnect(2)needssandbox.network.allowUnixSocketstoo, symptom and fix added; and a note that ssh transport (git push) cannot run from the sandbox at all (no DNS/TCP through the HTTP proxy).setup-isolated-setup-verifycheck 10 (overlay hooks wired, scripts matching the framework copies, toolkit probe run outside the sandbox by the user, signing key readable from sandboxed Bash);setup-isolated-setup-doctorprobe 5 (signing-key readability) and probe 1 naming the macOS socket case;setup-isolated-setup-updatelists the overlay scripts for drift.## The 3 probesvs## The 4 probes); brought in line, one new case each.git commit;); a marker file (touch /tmp/magpie-gpg-touch/debug) turns the watcher's log on where no variable can be set — the hook's environment — with a trace, the window's own output and the environment it drew from.ps, so the pre-commit run passes inside it.Verified end to end: both commits were signed from inside the sandbox with the hook-armed overlay providing the touch cue.
Migration path for existing adopters
Re-copy the hook scripts (
cp tools/agent-isolation/gpg-touch-overlay* ~/.claude/scripts/) — there is one new file. No config change. Linux behaviour changes only in that the watcher now outlives the first signature (untildisarm), which is what a multi-commit rebase needed anyway.Test plan
prek runon all touched files — every hook passes.pytest (workspace)has to run outside the isolated sandbox: it deniesps/pgrep("Operation not permitted"), which the session-leader andssh-keygen-detection tests need.tools/agent-isolation/tests/test_gpg_touch_overlay.py— 22 passed, 1 skipped (thegiprobe, expected on macOS). New tests:ssh-keygendetection (whole-name match, sossh-keygenxdoes not trip it), the session-leader guarantee of the spawn path,_tk_pythonreturning a resolved path whose Tk is ≥ 8.6, and the watcher outliving a signature that ends.arm→ fakessh-keygen→disarm): window up 1.7 s after the signature started, gone 0.2 s after it ended, watcher gone afterdisarm, no leftover process.gpg.format=sshon a YubiKey with the overlay up through the realarmpath — including the ~45 s of pre-commit hooks (with the look-alikessh-keygenfrom the test suite) before git signed. Esc dismisses the focused window.Notes for reviewers
The watcher still gives no cue for the auth touch on
git pushover ssh — that goes throughssh, notssh-keygen, andpushonly made it into the command matcher for--signedpushes. Same key, same silent block; matchingsshby name would also fire during any long transfer, so it needs a better signal than a process name. Out of scope here, worth a follow-up.🤖 Generated with Claude Code