Repository navigation
fix(agent-isolation): give every signing context its own touch watcher - #1301
Merged
Merged
Conversation
Two agent sessions signing at once, or a terminal git signing beside one, shared a single watcher pid file. Any of them could kill a watcher it had not started, which left a touch blocking with no window, and two arms that raced overwrote the only record of one, which left a window nothing could close until the ten-minute cap. Each signing context now owns its watcher, registered under owners/ and keyed by the harness session id its hooks carry or by the wrapper's own pid, and can tear down no other. A context whose owner process is gone is swept by the next arm rather than waiting out the cap. The window stays shared, leased by atomic directory create so one touch still draws exactly one, with the lease reclaimed from a holder that died. Generated-by: Claude Opus 5
7 of 21 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
gitsigning beside one, shared a single watcher pid file, so any of them could kill a watcher it had not started. The symptom is a hardware-key touch that blocks with no window on screen.Type of change
.claude/skills/<name>/) — eval fixtures updated belowtools/<system>/*.md)tools/*/withpyproject.toml)docs/,README.md,CONTRIBUTING.md)projects/_template/)prek, workflows, validators)tools/agent-isolation/shell substrate and its specWhat changed
A signing context is an agent session or a wrapped
git. Each now registers underowners/, keyed by the harness session id that both hooks carry in their payload or by the wrapper's own pid, and records two pids: the owner, whose death means the context is gone, and the watcher, which is the only process that context may kill. The wrapper no longer reuses a watcher somebody else started, which is what made a terminal signature's window depend on an unrelated session's disarm timing.The window is the one thing that must stay single, so it is leased by atomic directory create, the one primitive both macOS and Linux have without
flock(1). A lease left behind by a watcher that died is reclaimed rather than locking the window out for good. Dismissal became shared for the same reason: dismissing once should not be undone by another watcher a fifth of a second later.Stuck windows get a cure rather than a shorter wait. Each arm sweeps registrations whose owner process is gone and kills the watchers behind them, so a session that crashed without disarming costs nothing instead of a window that sits there until
MAX_WAIT. Hook-armed watchers also exit on their own if the harness process dies.Test plan
prek runpasses on every changed file, including the whole-workspacepytest,ruff,mypyandlycheehooksuv run pytestpasses intools/agent-isolationThe new tests are the concurrency the single pid file could not survive: two sessions get independent watchers; one session's disarm leaves another's watcher alone; re-arming the same session reuses its watcher; a dead owner's watcher is swept; only one of two racing watchers may hold the window lease; a lease is reclaimed from a dead holder; and the wrapper registers itself while leaving other owners untouched.
test_wrap_leaves_a_watcher_somebody_else_armed_aloneis retired. It asserted the piggybacking that was itself the defect, andtest_wrap_registers_itself_and_leaves_other_owners_alonecovers the concern behind it properly.RFC-AI-0004 compliance
Linked issues
None — reported from use.
Notes for reviewers
The behaviour this replaces was deliberate, not an oversight: one watcher covering whatever was in flight, with a test asserting the wrapper left it alone. That design is exactly what cannot survive concurrent owners, so the intent and the test both had to move. Worth a look at whether you agree with the trade.
Two places described the old behaviour and are updated in the same commit: the agent-isolation spec and the one-signature-one-window paragraph in the secure-agent-setup guide.
Worth knowing separately: the installed copy that actually runs in a session is usually a symlink into the operator's own dotfiles, and mine had already drifted from the repository before this change. Landing this does not update it.
Generative AI disclosure
Written with Claude Code (Opus 5) under human direction. The race was diagnosed from the script, the tests were written first and confirmed failing against the old behaviour, and the author reviewed the change before it landed.
🤖 Generated with Claude Code