fix(agent-isolation): disarm the touch overlay when a command never runs - #1316
Merged
Merged
Conversation
The documented arm/disarm wiring assumed every armed command eventually executes. `PreToolUse` fires before the permission prompt, so a command the operator rejects has already armed a watcher that `PostToolUse` never tears down. It then lives until `MAX_WAIT` — ten minutes — and because `signing_in_flight` is a machine-wide `pgrep` for `gpg` / `ssh-keygen` rather than something scoped to the armed context, any unrelated signature inside that window raises the window with nothing of the operator's pending. The visible symptom is the one the overlay exists to prevent: a touch landing while no signature waits fires the key's OTP slot and types `cccc…` into whatever has focus. Observed three times in one session. Wires `disarm` onto `PermissionDenied` and `PostToolUseFailure` — the events that fire when a Bash call does not run — in the setup doc, the install skill's K.2, the verify skill's check 10a, and the sandbox spec. `disarm` is already idempotent and exits 0 with nothing armed, so the extra calls cost nothing and no script change is needed. Generated-by: Claude Opus 5
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
PreToolUsefires before the permission prompt, so a command the operator rejects has already armed a watcher thatPostToolUsenever tears down.MAX_WAIT— ten minutes — and becausesigning_in_flightis a machine-widepgrepforgpg/ssh-keygenrather than something scoped to the armed context, any unrelated signature inside that window raises the window with nothing of the operator's pending.cccc…into whatever has focus. I hit it three times in one session before working out why.disarmontoPermissionDeniedandPostToolUseFailure— the two events that fire when a Bash call does not run — in the setup doc, the install skill's K.2, the verify skill's check 10a, and the sandbox spec.No script change is needed.
disarmis already idempotent and exits 0 with nothing armed (test_disarm_is_silent_when_nothing_is_armed), so the extra calls cost nothing. This is a wiring-and-docs fix.Type of change
isolated-setup-install(K.2),isolated-setup-verify(10a)tools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)Test plan
prek run --all-filespasses (32 hooks, exit 0)~/.claude/settings.jsonand verified it: JSON valid,disarmpresent on all three events,armstill onPreToolUse,disarmexits 0 with nothing armed, no watchers alive and no leftover registrations afterwards.PermissionDeniedactually fires. It only triggers when a human rejects a tool call, which the agent cannot do to itself. The event name is in the settings schema and the wiring validates, but the behaviour is unconfirmed. If it turns out not to fire, the fallback is shorteningMAX_WAIT— worth a reviewer with a spare moment rejecting onegit commitand checkingpgrep -f 'gpg-touch-overlay.*_watch'comes back empty.step-1-classifyschema isn: 1-10).RFC-AI-0004 compliance
Linked issues
None.
Notes for reviewers (optional)
signing_in_flightbeing machine-wide is what turns a leaked watcher into a wrong window rather than merely a wasted process. Scoping it to the armed context would be the stronger fix, but it is a behaviour change to the watcher with its own test surface, and this PR is meant to be the small correct one. Happy to follow up if you'd rather have that.🤖 Generated with Claude Code