šŸ› fix(kavach): pnpm --dir pack, pariksha's --root and git log -i pass, 0.8.3

Merged
AT
8d ago
+555-20

Slice: #404

Under work item #43. Page: https://claude.ai/artifact/5eNtsuuvsFuTDTCfZLWT3Y

These four commands were refused on 2026-11-21/22 while releasing pariksha 0.7.20 (#370, #393). Each writes nothing, or only inside the session's own worktree. I reproduced all four through the pinned sarathi 0.7.19 and kavach 0.7.19, as the hook runs them. Three now pass, each next to its write-shaped neighbour, which stays refused. The fourth is fixed in athya-rules.

1. pnpm --dir packages/pariksha pack --pack-destination ../../.tmp/pack

  • pnpm_selected_directory read the --dir folder only for exec and run. It now reads it for pack too, under --dir/-C only.
  • --pack-destination and --out are read from that folder. I probed pnpm 12.9: the tarball lands there.
  • The folder itself counts as a target, since pack writes its tarball there by default. So pnpm --dir .githooks pack, which kavach 0.7.19 passed, is refused.

The hole closed in the same reader

  • pnpm reads -C/--dir anywhere on the line, the last one winning, and reads it from the shell's folder. I probed this: pnpm --dir A exec --dir B pwd printed B. -w, -r and --filter in the slot move it too.
  • kavach 0.7.19 allowed pnpm --dir docs exec --dir . touch .githooks/pre-push, which runs touch in the root.
  • Now, with a folder selected, the line is unresolved if its subcommand's slot holds any of these: a folder-moving option (-C, --dir, -w, -r, --filter), --store-dir or --state-dir, or an option the reader does not list.
  • The slot runs up to the program or script for exec and run, and to the end of the line for pack. The nested reader (runner_program) refuses a slot --dir after a selector too.
  • A pack whose -C/--dir is not one selector before pack is unresolved too. kavach 0.7.19 passed pnpm pack --dir .githooks and pnpm --dir a --dir .githooks pack as naming no target, since a bare .githooks is not path-shaped.
  • These lines get their own refusal reason (pnpm_folder_unplaced), which says how to fix them: name the folder once, before the subcommand.
  • This can newly refuse a run line with an option before its script that pnpm's tables do not list, and such a line may have passed in 0.7.19.

2. pnpm --dir packages/pariksha exec node src/cli.ts boundary --root ../..

  • This was not a relative-path bug. An absolute --root was refused too, and so was the released pnpm exec pariksha boundary --root ..
  • The generic reader counts every path-shaped word of an unknown program as written, and refuse_named_root refuses a word that is the root.
  • pariksha_read_values now drops the values of a reading check's own options. Those checks are boundary (--root, --deny) and own-provenance (--config, --root), audited in pariksha 0.7.20's src/cli.ts.
  • The line must be the bare pariksha bin, or a bare node <file> where the file is src/cli.ts, or the bin, of the package named @veda-hq/pariksha. A .tmp/node does not count, and a pariksha that is not an installed bin is refused as one ("a bin that is not installed"). It must hold only that check's options, each with its value as the next word.
  • Still refused:
    • codeql-baseline and doc-references --write-baseline, which write under --root.
    • An extra word, --root=, or a node option before the script.
    • Another package's src/cli.ts.
    • pnpm exec prettier --write . and rm -rf ..
    • The same pariksha line from the main checkout, which the session does not own.
  • Not readOnlyCommands in veda's settings. That path returns before the ownership check and the push wait, and pnpm exec can install packages. So the same line from the main checkout could write there.
  • A look-alike manifest named @veda-hq/pariksha gains nothing that pnpm exec node .tmp/x.mjs does not already have. The README already says that repository code a command runs can write anything.

3. git log origin/main --oneline -i --grep=athya -5

  • The exact-name list that log, show and the other read verbs share gains git 2.54's options that choose commits or how they show: -i, -E, -F, -P, --all-match, --committer, --notes=, --word-diff=, and more.
  • I ran each one through git log -1 and git show. --min-parents and --max-parents take only the = form.
  • Still refused: --ext-diff, --textconv and --show-signature, which run programs, and --remerge-diff and --diff-merges, whose remerge writes objects.
  • --output is still read as a write, wherever it points.
  • git shortlog already passed -i; its --output and an abbreviation are pinned too.
  • One correction to the report: git 2.54 refused --outp= on log, show, diff and shortlog (probed). kavach refuses it all the same.

4. athya-rules agent wait: fixed in athya-rules, https://github.com/athya-hq/athya-rules/issues/127

  • wait only reads. But ~/.local/bin/athya-rules resolves the installed plugin on every run, and honours ATHYA_RULES_ROOT and ATHYA_RULES_NODE.
  • So kavach cannot bind the name to code it has read. Admitting it would let a session run any checkout as "read-only".
  • A shell wait such as until [ -e <out> ] || [ ! -e <out>.running ]; do sleep 2; done already passes kavach. So the router's instructions change instead.

Tests

  • ReportedFalseRefusalsTest runs each case through the adapter as sarathi runs it, with protectedPaths set like veda's. It carries the passing rows, their refused neighbours, the hole and the pack twins. The main-checkout rows assert the not-owned refusal.
  • ProtectedPathsTest's fixture moves into ProtectedFixture, so both classes share it.
  • Three corpus rows: git log -i --output=<main> is an attack; git log -i --grep and git show -i … are near-misses.
  • The rows that pass now were refused by kavach 0.7.19, and the hole's rows were allowed by it. I ran the same lines through the pinned sarathi before the fix.
  • pnpm --dir packages/kavach check passes: typecheck, Python tests, node tests with coverage, build.

Release: kavach and sarathi move to 0.8.3, with sarathi's VERSION in cli.ts. That is the next tag, per the 0114 coordinator, and I tag only on its go. Then veda's root pin of @veda-hq/sarathi moves to 0.8.3 in its own pull request.

What is still Alok's: these guards protect sessions only after the release, the pin bump, and pnpm install in the main checkout. The install is Alok's step.

Not done:

šŸ¤– Generated with Claude Code


Summary by cubic

Fixes three commands refused by kavach while releasing pariksha 0.7.20, and closes a hole in the same reader; kavach and sarathi move to 0.8.3.

  • pnpm --dir <pkg> pack now reads --pack-destination and --out from the selected folder and counts the folder itself as written, matching pnpm 12.9.
  • Reading pariksha checks (boundary, own-provenance) no longer count their --root, --config, or --deny values as written; write-shaped checks like codeql-baseline stay refused.
  • git log and git show accept git 2.54's search and display options (-i, -E, --all-match, --committer, and more); --ext-diff, --textconv, --show-signature, --remerge-diff, and --diff-merges stay refused.
  • Closed a hole: with a folder selected before the subcommand, a second folder-moving option in its slot (--dir, -C, -w, -r, --filter) or an unknown option leaves the line unresolved; --store-dir is read from the workspace root, or from --dir only outside a workspace (pnpm --dir docs exec --dir . touch .githooks/pre-push previously passed and ran in the root).
  • The fourth reported command, athya-rules agent wait, stays refused; the router's instructions change in athya-rules instead.