You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@magpie.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2026/09/20 22:58:21 UTC
[PR] fix(agent-isolation): give every signing context its own touch watcher [magpie]
potiuk opened a new pull request, #1301:
URL: https://github.com/apache/magpie/pull/1301
## Summary
- Two agent sessions signing at once, or a terminal `git` signing 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.
- Two arms that raced both wrote that file, so the loser's watcher became unreachable and ran on with its window up until the ten-minute cap. The symptom is an overlay that will not go away.
- Every signing context now owns its own watcher and can tear down no other. The window stays shared, leased rather than owned, so one touch still draws exactly one.
## Type of change
- [ ] Skill change (`.claude/skills/<name>/`) — eval fixtures updated below
- [ ] Tool / bridge contract (`tools/<system>/*.md`)
- [ ] Python package (`tools/*/` with `pyproject.toml`)
- [ ] Groovy reference impl
- [x] Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
- [x] Documentation (`docs/`, `README.md`, `CONTRIBUTING.md`)
- [ ] Project template (`projects/_template/`)
- [ ] CI / dev loop (`prek`, workflows, validators)
- [x] Other: `tools/agent-isolation/` shell substrate and its spec
## What changed
A signing context is an agent session or a wrapped `git`. Each now registers under `owners/`, 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
- [x] `prek run` passes on every changed file, including the whole-workspace `pytest`, `ruff`, `mypy` and `lychee` hooks
- [x] For Python packages touched: `uv run pytest` passes in `tools/agent-isolation`
- [ ] For Groovy bridges touched: command-line invocation tested end-to-end
- [ ] For skill changes: eval suite passes for the affected skill
- [ ] For skill *behaviour* changes: a new or updated eval fixture is included in this PR
- [x] Other: seven new tests, each confirmed failing against the old script before the fix was written
The 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_alone` is retired. It asserted the piggybacking that was itself the defect, and `test_wrap_registers_itself_and_leaves_other_owners_alone` covers the concern behind it properly.
## RFC-AI-0004 compliance
- [ ] **HITL** — any new mutation is gated on explicit user confirmation
- [x] **Sandbox** — no new host access; the change is confined to the runtime directory the overlay already used
- [ ] **Vendor neutrality** — placeholders used in all skill / tool prose
- [ ] **Conversational + correctable** — agentic-override path documented if behaviour is adopter-tunable
- [ ] **Write-access discipline** — no autonomous outbound messages; drafts only, sent on confirmation
- [ ] **Privacy LLM** — private content does not reach a non-approved LLM; redactor invoked where needed
## 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](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(agent-isolation): give every signing context its own touch watcher [magpie]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #1301:
URL: https://github.com/apache/magpie/pull/1301
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@magpie.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org