Repository navigation
feat(hooks): ask only for effects that escape the sandbox - #163
Merged
Merged
Conversation
Read-only programs take any argument, globs included, unless a redirection writes a file. Other programs with a run-time argument ask; a literal deny prefix such as rm -rf still denies. Script execution, in-place edits, and trivial builtins move from ask to allow inside the sandbox. Fetched packages, dependency changes, rm, merges, and publishing still ask. Running pip through python -m is denied like pip itself. Refs #162 Co-Authored-By: Claude Fable 5.1 <[email protected]>
ADR-0034 supersedes the ask tier of ADR-0031 now that the sandbox is the hard boundary. Closes #162 Co-Authored-By: Claude Fable 5.1 <[email protected]>
furedea
added a commit
that referenced
this pull request
Oct 15, 2026
…#165) ## Summary Claude Code matches its allow rules against every command in a call, so `cd repo && rg foo`, a pipeline into `sed`, `awk`, or `xargs`, and plain `cp`/`mv` were never rule-matched: `cd`, `sed` (without `-n` or `-i`), `awk`, `xargs`, `cp`, and `mv` had no allow entry. In auto mode the classifier then decided and sometimes prompted; in every other mode the call always prompted. That is where the remaining `rg`/`grep`/`jq` prompts came from after #163. All six are contained by the sandbox under ADR-0034: - `cd`: the verification scope check still asks for a target outside the worktree and temp directories, and for a run-time target. - `sed`, `awk`: writes stay inside the worktree, where Git restores tracked files; `sed -i` was already allowed. - `xargs`: the hooks already unwrap it and judge the wrapped command, so `xargs git add -A` is still forbidden. - `cp`, `mv`: replace the `-n`-only forms; the sandbox confines writes, and a glob or variable argument still asks. Closes #164 ## Verification - `uv run --frozen pytest tests/agents`: 1502 passed. - `ruff check`, `ruff format --check`, and dprint are clean; lefthook pre-commit and commitlint passed. - Live check after `home-manager switch`, in a new session: `cd agents && rg -n foo lib` and `find . -name '*.py' | xargs grep -l foo` should run without a prompt; `cp *.md backup/` should ask. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5.1 <[email protected]>
This was referenced Nov 11, 2026
furedea
added a commit
that referenced
this pull request
Nov 12, 2026
agent-config の最新を取り込みます.#74 のモデル判定の改善がまとめて入ります.#452 の置き換えです(#452 はこの PR の前の版の `flake.lock` でした). | 取り込む変更(furedea/agent-config) | 中身 | | --- | --- | | #157 | Stop に判定の秒数を出す.`model-rules/**/fixtures/**` をモデル判定に送らない | | #160 | `model-rules/*/fixtures/*` をテストの検証で数えない | | #163 | Python と TypeScript の誤検知を直す(M-05 は原則の書き直しと基準値,M-21 は送る範囲を `located` に) | | #167 | 保存結果の数を下見から取る | | #158 | Go と Rust の M-05,M-21,M-60 を追加.保存した基準を相対パスで取り直した | | #170 | Stop の表示を `jev-lint: 0 findings · 74 subjects · passed · $0.0004 · 4.3s` の 1 行にする | - [x] `darwin-rebuild switch` で反映済み 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: furedea <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the OS sandbox the safety boundary for ordinary commands and asks only for effects that escape it or cannot be undone. Audit evidence from one afternoon after #159: 94 hook escalations, 82 of them "syntax" (a glob,
$VAR,$(...), or heredoc anywhere in the call), the restgrep/rg/catarguments that merely contained\or$inside quotes; script execution prompted on every call.$HOMEas dynamic and keeps its source text instead of raising. Command, process, and arithmetic substitution, heredocs, and dollar-quoted strings are still refused.rg,grep,cat,ls,find,jq, and the other programs listed inallowed_commands.jsonmay take any literal, glob, or variable argument as long as no redirection writes a file (/dev/nulland fd duplication are fine).rg -n "def \w+" agents,rg foo *.py, andcat $FILEare allowed;rg foo > out.txtstill asks.git push $FLAGS,cd $DIR, and a dynamic program name. A literal deny prefix such asrm -rf $DIRstill denies, and the forbidden hook no longer escalates; escalation is the allowed hook's job.python3,python,node,uv run python,uv run --frozen python(scripts,-c/-e, and a short module list),sed -i,perl -i,tee,truncate.python -m pipis denied likepip.uvx,npx,pnpm dlx,bunx, dependency changes,rm, merges, publishing, and the sandbox escape still ask.echo,printf,pwd,date,true,false,test,basename,dirname,realpath,readlink,seq) are allowed so they no longer reach the classifier.cdorgit -Cto a run-time directory asks in the verification scope check instead of resolving a literal$DIRpath.Closes #162
Verification
uv run --frozen pytest tests/agents: 1492 passed.uv run --frozen ruff check,ruff format --check, andty checkare clean; lefthook pre-commit and commitlint passed on both commits.uv run pythonandsed -inow expectallow;uvxandnpxrows expectprompt.home-manager switch: runrg -n "def \w+" agentsandpython3 -c 'print(1)'in a new session and confirm neither prompts; runrg foo > out.txtand confirm it asks.🤖 Generated with Claude Code