šŸ› fix(kavach): a git config read under -C passes, wherever -C points, 0.8.7

Merged
AT
7d ago
+229-4

kavach 0.8.3 refused read-only git config under -C when -C pointed anywhere but the session's own worktree. It counted the -C folder as written, because git_is_read_only (packages/kavach/python/kavach/boundary.py) had no case for config. Both commands reported on 2026-11-23 now pass:

  1. git -C <main checkout> config --show-scope --show-origin --get-all core.hooksPath, refused before for "holds …/.githooks, a path worktree.protectedPaths keeps from agent sessions"
  2. git -C <another worktree> config --show-scope --show-origin --get-all core.hooksPath, refused before for "is outside this session's Claude worktree"

The change

  • git_config_is_read counts a command as a read only when it is the get or list subcommand, a reader option (--get, --get-all, --get-regexp, --get-urlmatch, --get-color, --get-colorbool, --list, -l) or a lone key. Every other option must be a display, type or location option, matched by exact name.
  • These stay writes: --unset, --unset-all, --add, --replace-all, --remove-section, --rename-section, key value, set, unset, --edit, -e and edit.
  • These are not counted as reads either: -- (after it --list is a value), an abbreviation (--get-al), a short cluster (-le), a value option given an option (--file --unset) and a word the shell computes.
  • git_is_read_only uses it together with git_globals_are_inert, so --git-dir, --work-tree and -c before config stay unproven.
  • kavach's README lists the new read form under "What read-only means".
  • kavach and sarathi move to 0.8.7. v0.8.6 was tagged for #434 while this waited, with sarathi 0.8.6 on kavach 0.8.3; sarathi 0.8.7 depends on this kavach.

Evidence

  • New GitConfigReadUnderCTest (packages/kavach/python/tests/test_worktree_guard.py) runs each case through the adapter as sarathi runs it, with .githooks/ protected:
    • 19 read forms pass against the main checkout, another worktree and the session's own worktree;
    • 18 write forms are refused against the main checkout and another worktree.
  • Red: with the config branch switched off, the read test fails 38 times, with exactly the two reported refusals (19 per folder).
  • Hand mutants, both killed: accepting two positionals fails config core.hooksPath /dev/null and config user.name corpus; accepting an option as a value's value fails config --file --unset core.hooksPath.
  • Corpus: new rows that must pass, git -C {P} config reads (outside-write and hook-bypass); new rows that must stay refused, an --unset, --add or --replace-all of core.hooksPath under -C {P}, and git -C {P} config -f pwned core.x y. The oracle confirms each row's truth.
  • pnpm test:python: 933 tests OK. pnpm test (kavach TS and corpus): 767/767 pass.

The mutation gate's kavach lane covers only packages/kavach/src/*.ts, which this change does not touch.

Slice: #436

šŸ¤– Generated with Claude Code