š fix(kavach): from another repository, the cd back passes, 0.7.15
Under work item #43.
kavach's cd-out-of-worktree rule took the shell's current checkout as the session's. From a folder in another repository, it flagged the cd back to the session's worktree. Once a consumer sets the rule to refuse, that strands the session where the worktree guard refuses every write.
What changes:
- The rule passes a
cdwhen both of these hold:- the shell's checkout is one the worktree guard takes as no session's own (another repository, or a main checkout);
- the target's checkout is one it takes as a session's own (a worktree under
.claude/worktrees, or theworktree.ownCheckoutclone).
- Both guards share that test.
owns_plain_checkoutmoves fromworktree_guard.pytoboundary.py, next to a newownable_checkout.judge()gives the detectors the settings (Call.settings), so the rule can readworktree.ownCheckout. - Once the way back passes, a later
cdin the same command is judged from the checkout it entered, as the session's. For example,cd <session> && cd <other>fires with the session's worktree named. This goes beyond the slice's table, and came from Cubic's review. - The rule asks about ownership only for a
cdthat leaves the checkout. Acdinside it costs no git starts, and an error in the lookup cannot refuse it. - From a checkout the guard takes as no session's own, the message calls no checkout "this session's". It no longer says to
cdinto the shell's checkout; it says that acdinto the session's own worktree brings the shell back. - kavach and sarathi move to 0.7.15, including sarathi's
VERSIONincli.ts. pariksha stays at 0.7.14.
Deliberate, from the slice's table:
- One warning is lost. A session started in a main checkout, with no worktree, can now
cdinto any managed worktree of that repository without the "another session may own" warning. From there, the rule cannot tell the session's worktree from another session's. - The plain-clone wording changed. The message now reads "takes as no session's own" from every checkout that is neither managed nor the
ownCheckoutclone. That includes the default-config case an exact-stderr test used to pin. That guard-level test now runs with anownCheckoutconfig, so it still checks the owned wording. The unit tests cover the wording without one. - Not here: a shell stuck in another session's managed worktree (#349, "Not here").
Tests:
pnpm checkpasses, including kavach's Python suite.- New unit tests in
test_rules.py:- from another repository, or from a main checkout, the
cdinto a managed worktree passes, and so does thecdinto theownCheckoutclone; - from another repository, a
cdelsewhere names no checkout as the session's; - from a managed worktree, and from the
ownCheckoutclone, acdinto another repository's managed worktree still fires; - a
cdinside the checkout never asks about ownership; - from a peer worktree, the
cdback to theownCheckoutclone passes, while without that config it still names the peer.
- from another repository, or from a main checkout, the
- A new subprocess test runs
command_guard.pywith the rule set torefuseand the cwd in another repository:cd <managed worktree>exits 0;cd <third repository>exits 2 with the neutral message.
Not checked yet: one event through veda's real sarathi.sh. The hook loads sarathi and kavach from the registry at the root pin, which is 0.7.14, so this code can reach it only after v0.7.15 and the pin bump. I'll run it on the pin-bump PR, with the worktree's .claude/kavach.json setting the rule to refuse (sarathi.sh passes it as KAVACH_CONFIG). Until then, the subprocess test through command_guard.py stands in for it.
Ships: v0.7.15. After that come a pin bump of @veda-hq/sarathi, then Alok's pull and pnpm install in the main checkout, both at once.
š¤ Generated with Claude Code