š§ chore(claude): the guard refuses a write in another live session's worktree
Slice: #691
kavach's other-sessions-worktree rule has warned in niyam since kavach 0.7.19, because .claude/kavach.json did not name it. This PR sets it to "refuse", as veda did in https://github.com/veda-hq/veda/pull/606. The analysis is at https://claude.ai/artifact/U1YQxUjUMjF6kt5rnFUhZP. Alok approved with a š on https://github.com/veda-hq/niyam/issues/691#issuecomment-7199534852.
Change: .claude/kavach.json gains "rules": { "other-sessions-worktree": "refuse" }. Nothing else changes.
Evidence: I ran crafted PreToolUse events with KAVACH_REFUSAL_LOG_OFF=1, so no rows reached the log. Each event went two ways:
- through the main checkout's
.claude/hooks/sarathi.sh PreToolUse, today's config, which warns; - through kavach 0.8.9's worktree guard with this branch's
.claude/kavach.json, which refuses.
They used this session's real session_id and host id. The peer was goofy-einstein-a1dda6, whose app record is live.
| Event | Main (warn) | This branch (refuse) |
|---|---|---|
Bash touch in a live peer's worktree | exit 0, warns | exit 2, names the cd back |
| Write in a live peer's worktree | exit 0, warns | exit 2 |
Bash ls there (a read) | silent | silent |
cd back to own worktree from the peer's | silent | silent |
touch in own worktree | silent | silent |
touch in a worktree whose records are all archived | silent | silent |
touch in a worktree no record names | silent | silent |
touch in the peer's with a wrong session_id | silent | silent |
touch in the peer's with no host session id (CLI) | silent | silent |
pnpm check exits 0, with 2935 of 2935 and 138 of 138 tests passing.
After the merge, the main checkout pulls the change. I then re-run the same events through its hook, as the slice's done-when asks.
š¤ Generated with Claude Code
Summary by cubic
Changes kavach's other-sessions-worktree guard from warning to refusal, so writes in another live session's worktree are now blocked instead of just warned about. Reads there, cd back to your own worktree, and writes to your own or archived worktrees stay silent.