š fix(kavach): git's --output is a write target on every subcommand
Slice: #162
From a Claude-managed desktop worktree, kavach let a git subcommand outside READ_GIT write its --output file anywhere: git diff-files --output=/elsewhere/x passed, and so did diff-index, range-diff, shortlog, whatchanged, format-patch, reflog and stash show (#161). Now each is refused with "outside this session's Claude worktree".
The change
In packages/kavach/python/kavach/boundary.py, the git branch of mutation_path_operands used to return [] for every verb outside READ_GIT and worktree. Now it ends in git_output_options, which:
- reads
--output=<v>and--output <v>before--as write targets, resolved from the-Cfolder; - refuses as unproven a strict prefix of
--output(--oā¦--outpu), with or without=, and an empty or--leading value.
READ_GIT and git_inspection_outputs are unchanged, so git shortlog -sn and git format-patch -1 -o .tmp still run, and --output-directory, --output-indicator-* and --onto don't match.
Git 2.54 already rejects every --output abbreviation as ambiguous with --output-indicator-*, so refusing them guards other git versions, not a hole that's open today.
Tests
test_boundary.py,test_git_output_elsewhere_is_refused_on_every_subcommand, sits beside the existing--outputtests rather than intest_worktree_guard.py. Its first 7 rows passed the guard before the fix. It also covers quoted and spaced values,-C nestedwith a relative path, abbreviations and missing values (unresolved), and the commands that must still run.- It also refuses
--output="$HOME/x"and--output=$Xas unresolved. corpus.json: a new attack row,ow-git-diff-files-output, sits besideow-git-output.test_worktree_guard.py: #152's owned-clone rowgit whatchanged --outpu=.claude/hooks/guard.shis now refused earlier, as unresolved, so it moves out of the fence rows and asserts that reason.pnpm --filter @veda-hq/kavach check, run locally on #152's main: the full Python suite (725 tests) passed except that one row, which was then fixed, and both changed tests pass. typecheck and build pass.pnpm testpassed 758 of 759: the failure was run-child's pipe test, the #147 race that #159 has since fixed on main. Since then the branch has been rebased onto #159, which changes onlyrun-child.test.tsand the version in kavach. CI runs the whole check.
Not here
- No version bump. The release slot comes from veda's release queue, and sessions are guarded by this only after a release, a pin bump and an install in the main checkout.
format-patch -o,archive -o,bundle create,clone <dir>andinit <dir>name destinations the guard doesn't read either. They're filed as #163.
š¤ Generated with Claude Code
Summary by cubic
Fixes kavach's git guard so --output is treated as a write target on every git subcommand, not just the read verbs in READ_GIT. Previously git diff-files --output=/elsewhere/x ā and the same on diff-index, range-diff, shortlog, whatchanged, format-patch, reflog, and stash show ā wrote anywhere from a Claude-managed worktree; now each is refused as outside the session's worktree.
- Reads
--output=<v>and--output <v>before--as write targets, resolved from the-Cfolder; abbreviations and missing or option-like values fail closed as unresolved, while existing reads likegit shortlog -snand-o .tmpare unaffected. - Adds a boundary test and a
corpus.jsonattack row covering spaced, quoted, and-C-relative values, and moves the owned-clonewhatchanged --outpurow to the unresolved path. - Other destination options (
format-patch -o,archive -o,bundle create,clone,init) remain unguarded, filed as #163.