🔧 chore(kavach): rule other-sessions-worktree refuses in veda
Slice: #588
State: #605
Refs #363
Under work item #43. This is the last step slice #588 named. Alok chose option B on 2026-11-25 ("B, refuse now"), recorded on #363: https://github.com/veda-hq/veda/issues/363#issuecomment-7159865990.
.claude/kavach.json sets "rules": { "other-sessions-worktree": "refuse" }. The rule's trial in veda ends. A write by a session whose shell is in another live session's worktree is refused, with the cd back to its own worktree; it no longer warns and runs. kavach 0.8.9, pinned by #604, logs a scan-failed row when its scan of the desktop app's records fails, and a failed scan never refuses.
Checked locally, through this worktree's install of sarathi and kavach 0.8.9 and this branch's .claude/kavach.json. .tmp/probe-588.ts sent crafted PreToolUse events through bash .claude/hooks/sarathi.sh PreToolUse, with CLAUDE_PROJECT_DIR set to the worktree and this session's own CLAUDE_CODE_HOST_SESSION_ID. The refusal log was off.
| Event | With the trial (#604) | With this change |
|---|---|---|
Bash touch, cwd in another live session's worktree (confident-herschel-f502fc), this session's session_id | exit 0, the trial warning | exit 2, BLOCKED: the shell is in worktree confident-herschel-f502fc, which another live session works in… with the cd back |
| Write, the same | exit 0, the trial warning | exit 2, the same refusal |
ls there; a wrong or missing session_id; no CLAUDE_CODE_HOST_SESSION_ID | exit 0, silent | exit 0, silent |
| own worktree, or a worktree no live record names | exit 0, silent | exit 0, silent |
.claude/kavach.json is not a guard file. Sessions read the main checkout's copy, so the rule refuses once the main checkout pulls this.
After merge: the main checkout still has sarathi 0.8.7 installed. The same pull brings #604's pin to 0.8.9, so Alok pulls main and runs pnpm install there, both at once. Until the install, sarathi.sh refuses every PreToolUse call in every live session.
athya_mono and niyam each need their own pin bump and rules entry; neither is part of this slice.
🤖 Generated with Claude Code
Summary by cubic
Ends the other-sessions-worktree trial in veda: a write from a session whose shell is in another live session's worktree is now refused (exit 2, BLOCKED, with a cd back) instead of warned and run. Read-only commands, wrong or missing session IDs, and the session's own worktree stay silent, and a failed scan of the desktop app's records (kavach 0.8.9, pinned by #604) logs a scan-failed row and still never refuses.
After merge
- The rule activates when the main checkout pulls this change, since
.claude/kavach.jsonis not a guard file. - Until
pnpm installruns in the main checkout after the pull,sarathi.shrefuses every PreToolUse call. athya_monoandniyamneed their ownkavachpin bumps andrulesentries; neither is part of this slice.